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

Nicola Mingotti nmingotti at gmail.com
Thu Aug 12 01:17:58 PDT 2021


Hi Gerald,

On 8/12/21 9:11 AM, Gerald Klix wrote:
> May I suggest to to implement it this way:
> --- snip ---
> Json readFrom: aString readStream
> --- snap ---
> (See SequenceableCollection>>#readStream, inherited by String))
>
your version is nicer to the eye ;)

There is something i don't understand though. I can arrive up to
PositionableStream class>> on:
---------------
on: arg1
     ^ self basicNew on: arg1.
---------------
After that, I can't find where "basicNew on:" is implemented.


> If your JSON documents are bigger, it might be more efficient
> to convert the HTTPSocket to a SocketStream and read directly from
> it, but I do not know whether this is possible without much effort.

Actually the JSON strings I send/receive can be a bit large. Because 
they represent objets with inside
packed quite a bit of information e.g. pictures. I would say never 
larger then 1 MByte, if possible.

Still at the moment I will not worry about efficiency. I am trying to 
convert a Ruby+Mongo
server side of an app into Cuis. I have time till end of the month to 
make it work.

For the moment I am going to replicate the database as a list of objects 
in memory,
I will consider persistency better in a second step ;)

Bye
Nicola



>
> On 8/12/21 8:49 AM, Nicola Mingotti via Cuis-dev wrote:
>> 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
>>
>>
>>
>>
>>



More information about the Cuis-dev mailing list