Search code examples
javajsonjsonserializer

Json Deep serialize


In a case where Person is a POJO having a List of "hobbies".

Just trying to understand this statement to implement a deep serialize mechanism:

new JSONSerializer().include("hobbies").serialize( person ); 

Does the syntax seem intuitive? From a java user POV, it seems the syntax should be:

new JSONSerializer().serialize( person ).include("hobbies"); 

I say this because it seems intuitive first to serialize the priamry object and then any Lists, references thereof.

Also, is the source code of flexjson available for public use? It is not present on sourceforge.net


Solution

  • You cannot do the latter so easily - the implementation would not know when you are done. You need to have some kind of terminator that performs the action, such as as .run() or .done()..