From c09b91c901ec94e74c6fbd55247cce3f3d0d42b0 Mon Sep 17 00:00:00 2001 From: svenvc Date: Wed, 27 Mar 2024 09:44:52 +0100 Subject: [PATCH] improve class side instance creation of NeoJSONObject --- .../Neo-JSON-Core/NeoJSONObject.class.st | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/repository/Neo-JSON-Core/NeoJSONObject.class.st b/repository/Neo-JSON-Core/NeoJSONObject.class.st index 5943169..4c62cfb 100644 --- a/repository/Neo-JSON-Core/NeoJSONObject.class.st +++ b/repository/Neo-JSON-Core/NeoJSONObject.class.st @@ -148,16 +148,30 @@ NeoJSONObject class >> exampleSimpleWriting [ ] { #category : #convenience } -NeoJSONObject class >> fromString: string [ - "Parse string as JSON, so that maps become instances of me" +NeoJSONObject class >> fromStream: readStream [ + "Parse stream as JSON, so that maps become instances of me and lists instances of NeoJSONArray" - ^ (NeoJSONReader on: string readStream) + ^ (NeoJSONReader on: readStream readStream) mapClass: self; listClass: NeoJSONArray; propertyNamesAsSymbols: true; next ] +{ #category : #convenience } +NeoJSONObject class >> fromString: string [ + "Parse string as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + + ^ self fromStream: string readStream +] + +{ #category : #convenience } +NeoJSONObject class >> readFrom: readStream [ + "Parse stream as JSON, so that maps become instances of me and lists instances of NeoJSONArray" + + ^ self fromStream: readStream +] + { #category : #accessing } NeoJSONObject >> at: key [ "I return nil for missing keys.