[Cuis-dev] [IMPROV] Add convenience method to read JSON strings

Nicola Mingotti nmingotti at gmail.com
Wed Aug 11 23:49:45 PDT 2021


Hi guys and Juan,

I frequently need to parse JSON data. It comes mostly from the web and 
it is 100% of
the time a string. I did not find something equivalent so I made my own.

I am using it frequently, i think it is useful, if something equivalent 
does not exist
I would add it to the Json class.

----- example ----
Feature require: 'JSON'.

Json readFromString: '{"a": "alpha", "b": [1,2,3]}'.
----------------------

attached fileout

bye
Nicola



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210812/4de258bf/attachment.htm>
-------------- next part --------------
'From Cuis 5.0 [latest update: #4738] on 12 August 2021 at 8:46:37 am'!

!Json class methodsFor: 'as yet unclassified' stamp: 'NM 8/12/2021 08:45:14'!
readFromString: aString
	"Frequently one must decode a JSON-string. Convenience method to reduce typing."
	|strx|
	strx _ ReadStream on: aString from: 1 to: (aString size).
	^ Json readFrom: strx.

! !



More information about the Cuis-dev mailing list