Hello, I've been playing with BaseX lately and all-in-all am very impressed. Something I'm wrestling with however is the JSON output options. I've got various web applications that would really be simplified by receiving JSON straight away for the obvious scripting benefits.
The JSON method has been giving me a lot of grief, stipulating rules I'm not sure how to follow. right now I have an element that "is typed as string and cannot be nested."
I've been able to get JSONML to output but the JSON is this morass of nested Arrays... Attributes seem to get transformed into Objects but elements/tags and their values are pushed into Arrays for some rationale - which I suppose is on purpose.
My question is how can I get Objects for simple key:value properties from <tag>value</tag> 's. Are there options I'm not utilizing? Would it be feasible to transform the XML output to some middle form first - setting it up to become Objects, before serializing it to JSON?
Thanks! Zach Pride Associate Software Engineer
Ultra Electronics, ProLogic 1000 Green River Drive, Ste. 201 Fairmont, WV 26554
zachary.pride@ultra-prologic.com Tel: +1 304 333 2680 ext.308
www.ultra-prologic.com
This e-mail from Ultra Electronics, ProLogic and any attachments to it are confidential to the intended recipient and may also be privileged or controlled by U.S. export control laws and regulations. No technical data, information or other items provided by Ultra Electronics, ProLogic in connection with this email shall be shared or provided to any foreign persons, entities, or subsidiaries without the expressed written authorization of Ultra Electronic, ProLogic. If you have received it in error please notify the sender and delete it from your system. If you are not the intended recipient you must not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
All communications may be subject to interception or monitoring for operational and/or security purposes. Please rely on your own virus checking as the sender cannot accept any liability for any damage arising from any bug or virus infection. This e-mail from Ultra Electronics, ProLogic and any attachments to it are confidential to the intended recipient and may also be privileged or controlled by U.S. export control laws and regulations. No technical data, information or other items provided by Ultra Electronics, ProLogic in connection with this email shall be shared or provided to any foreign persons, entities, or subsidiaries without the expressed written authorization of Ultra Electronic, ProLogic. If you have received it in error please notify the sender and delete it from your system. If you are not the intended recipient you must not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
All communications may be subject to interception or monitoring for operational and/or security purposes. Please rely on your own virus checking as the sender cannot accept any liability for any damage arising from any bug or virus infection.
Please consider the environment before printing this email.
On Wed, 2013-01-30 at 17:40 +0000, Zachary Pride wrote:
In XML, the order of elements is significant. Consider the paragraphs in a chapter of a book, for example :-)
I'll have to let others answer about generating JSON with BaseX, although another option is to write a function yourself to do it, and generate text that happens to be JSON.
Liam
True, I realize the structure of XML is a topic in and of itself as far as IA is concerned. What I'm wondering is how I can get my XML into key: values JavaScript Objects.
I think a good example of the kind of serialization/output I'm looking for is how the translation works on this site: http://www.utilities-online.info/xmltojson/#.UQqMi_JyGSo
I realize JSONML is a separate concept intending to provide lossless conversion between XML and JSON. In my situation I'm not concerned with multiple translations and communications. I want simple, quick access to my data without the need for looping and inspecting Arrays. From what I can tell from the BaseX documentation it's possible to get this form, I'd just like to know what I need to set to get the JSON I want.
Thanks! Zach Pride Associate Software Engineer
Ultra Electronics, ProLogic 1000 Green River Drive, Ste. 201 Fairmont, WV 26554
zachary.pride@ultra-prologic.com Tel: +1 304 333 2680 ext.308
www.ultra-prologic.com
This e-mail from Ultra Electronics, ProLogic and any attachments to it are confidential to the intended recipient and may also be privileged or controlled by U.S. export control laws and regulations. No technical data, information or other items provided by Ultra Electronics, ProLogic in connection with this email shall be shared or provided to any foreign persons, entities, or subsidiaries without the expressed written authorization of Ultra Electronic, ProLogic. If you have received it in error please notify the sender and delete it from your system. If you are not the intended recipient you must not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
All communications may be subject to interception or monitoring for operational and/or security purposes. Please rely on your own virus checking as the sender cannot accept any liability for any damage arising from any bug or virus infection. This e-mail from Ultra Electronics, ProLogic and any attachments to it are confidential to the intended recipient and may also be privileged or controlled by U.S. export control laws and regulations. No technical data, information or other items provided by Ultra Electronics, ProLogic in connection with this email shall be shared or provided to any foreign persons, entities, or subsidiaries without the expressed written authorization of Ultra Electronic, ProLogic. If you have received it in error please notify the sender and delete it from your system. If you are not the intended recipient you must not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
All communications may be subject to interception or monitoring for operational and/or security purposes. Please rely on your own virus checking as the sender cannot accept any liability for any damage arising from any bug or virus infection.
Please consider the environment before printing this email.
Hi Zachary,
there are numerous JSON uni- and bidirectional JSON-XML converters out there, all of which have certain flaws (see e.g. [1]). We have implemented JSONML for creating JSON outputs from arbitrary XML documents, but we are not particularly satisfied with it. A short time ago, I proposed to add some more JSON converters to our converter family on this list [2]; feel free to continue this discussion.
Best, Christian
[1] http://onwebdevelopment.blogspot.de/2008/05/converting-xml-to-json.html [2] http://www.mail-archive.com/basex-talk@mailman.uni-konstanz.de/msg01863.html
___________________________
On Thu, Jan 31, 2013 at 4:35 PM, Zachary Pride Zachary.Pride@ultra-prologic.com wrote:
Use this tool to analyze/convert tour json object http://codebeautify.org/view/jsonviewer
basex-talk@mailman.uni-konstanz.de