Hi Victor,

I would first suggest you read the following two book chapters:

https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/NeoJSON/NeoJSON.html

https://ci.inria.fr/pharo-contribution/job/EnterprisePharoBook/lastSuccessfulBuild/artifact/book-result/STON/STON.html

These should explain the basics and answer a lot of your questions.

Now, from a higher level, you have to understand that without an explicit 
mapping, arbitrary object encoding cannot work for JSON.

Furthermore, since there is no type encoding in JSON, parsing back to the 
original types cannot happen without help, again using an explicit mapping.

In Pharo/Smalltalk, contrary to Java, we are not used to full type descriptions.

Both NeoJSON and STON offer lots of options to do mapping, see the links above 
to get started.

HTH,

Sven 

> On 20 Mar 2020, at 02:20, Vitor Medina Cruz <vitormc...@gmail.com> wrote:
> 
> Hello,
> 
> I know two projects of json encoding/decoding — NeoJson and STON.
> 
> In Java I have two most used ones too: Gson and Jackson. Using those I can 
> simply pass any object and it they can convert to a json string, the former 
> can't deal with cycles, the latter can with some little config.
> 
> NeoJson seems to be limited to primitives, for example, in Pharo 8 I can't 
> run 
> 
> NeoJSONWriter toString: (Date today)
> 
> Since I got:
> 
> NeoJSONMappingNotFound: No mapping found for Date in NeoJSONWriter
> 
> 
> STON works fine with 
> 
> STON toString: (Date today).
> 
> but fail with:
> 
> STON toJsonString: (Date today).
> 
> Also, STON fails if I try to serialize an object which contains an instance 
> variable pointing to a block closure. I didn't find out how to ignore these 
> instance variable as it is unnecessary for what I need at the moment. 
> 
> So, which lib for json or some object/string encoding/decoding should I be 
> using on Pharo? Is there something better than those libs? Am I doing 
> something wrong? My experience tells this should be simple, but it is not.
> 
> Thanks in advance,
> Vitor


Reply via email to