Title: XML vs. JSON serialization Post by: Enrico S. on October 22, 2019, 05:16:49 pm Hi,
If I'm not in error, in XML serialization field names and fields order must match in both XML node structure and Genero record structure, while in JSON serialization these match are not required. Is it a choice ? Could we expect in a future release these XML constraints to be overcome ? Best Regards. Enrico Title: Re: XML vs. JSON serialization Post by: Reuben B. on October 24, 2019, 12:17:20 am There are some options that relax the requirements, see the two ignoreunknown attributes here http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/r_gws_XmlSerializer_option_flags.html as well as attributes such as XMLOptional that may help you.
However if your question is more about the order, and you are asking as with an example like the following ... Code
why you can swap the order for JSON and it will still parse, but if you swap the order for XML it won't parse. I think the answer to this lies by using the XMLALL attribute http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_gws_XML_attribute_XMLAll.html By changing the above example to have Code
then it runs which I suspect is what you are after. Why do you need the option, and why does it not work by default, note that with a JSON string, the element name is unique, whilst the XML Node Name is not necessarily unique Reuben Title: Re: XML vs. JSON serialization Post by: Enrico S. on October 24, 2019, 08:36:22 am Hi, Reuben. I understand.
The "why" is that in past third-party developers was asking me to ignore fields order (they was manually serializing SOAP messages). Now I simply wanted to go in deep to this argument and I was asking for your point of view. But I was not considering the uniqueness of JSON node names against XML. Thanks a lot for your answer. Enrico. Title: Re: XML vs. JSON serialization Post by: Rene S. on October 24, 2019, 08:39:20 am Some fun:
Code
Code: $ fglcomp test && fglrun test Title: Re: XML vs. JSON serialization Post by: Enrico S. on October 25, 2019, 03:02:16 pm Nice.
Not so well explained in manuals the meaning of @chars attribute name of Text nodes (it is new for me), but searching in deep from your sample it is possible to understand. Every time I ask something, you let me know a further small brick. Thanks again. Enrico Title: Re: XML vs. JSON serialization Post by: Sebastien F. on October 28, 2019, 09:31:33 am Hello Enrico,
Your suggestions to improve the documentation are welcome. Please use the feedback facility when something is missing or unclear. We talk about the @chars attribute and tagname in the following pages: http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassDomNode_getAttribute.html http://4js.com/online_documentation/fjs-fgl-manual-html/index.html#fgl-topics/c_fgl_ClassDomDocument_createChars.html However, I agree that it is missing here: http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_ClassDomNode_getTagName.html Do you expect something else? Seb |