Skip to content

Commit

Permalink
improve class side instance creation of NeoJSONObject
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvc committed Mar 27, 2024
1 parent 1d81fa2 commit c09b91c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions repository/Neo-JSON-Core/NeoJSONObject.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c09b91c

Please sign in to comment.