Hi Sven, 2013/3/18 Sven Van Caekenberghe-2 [via Smalltalk]
There is however a problem: the basic JSON spec is deliberately limited and vague about certain aspects, and even non existing for other aspects such as typing, references or cycles. There exist numerous ways to add those to JSON, some very complicated ones, often coming from statically typed languages. Many of those kill the human readability/writability of JSON. The problem of how to encode a type or class in JSON across languages is actually unsolved. That is why I decided not to implement any support for that.
With NeoJSON mappings your are supposed to know upfront what types your JSON represents/contains. This works fine in many cases but certainly not all.
In this case I know it. And I Just need the writter and not the reader, altough it might be useful in the future.
Circular references will always be a problem. Structure sharing is extra complicated, it requires both reader and writer support with an objet table.
Yes, this happens with any serializer without global state or object table :)
STON, which is very similar but incompatible with JSON, has support for all these aspects, right out of the box, no mapping required. If you do not have to interact with foreign systems, that is an option.
In this case JSON is mandatory. The consumer of the data is a mobile device. The other alternative is, god forbid, XML, which isn't friendly in terms of bandwidth.
Support for one of the many semantics built on top of JSON will have to be built by hand. Hopefully the mapping layer can help there. But like you said: you'll have to play with custom mappings. The mapping system is pretty simple to understand.
Yes, but sometimes I feel the need to be able to map instVars/accesors to encoder/decoders without having to use an schema (defined by a symbol). I haven't found the case where it is not an extra step.
PS: I also have to confess that although I am using NeoJSON in various important projects myself, we usually stick with Dictionaries/Collections without doing any mapping. Only in very specific cases do we actually convert to specific Smalltalk objects.
Same happens here so far, I produce JSON, and get JSON back, but then I manually pick the JSON values (deserialized as Dictionaries/Arrays) and assign them to my objects. I don't know what the guys from SmalltalkHub are using to serialize/deserialize JSON. Thanks for your support. I'll keep with using custom mappings for almost everything that references an object which isn't "simple" (string, dates, numbers, etc.). Best regards, -- Esteban. -- View this message in context: http://forum.world.st/NeoJSON-Mappings-tp4677077p4677222.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.