[x3d-public] X3DJSONLD ... converts XML to JSON client side!

John Carlson yottzumm at gmail.com
Tue Mar 20 09:43:04 PDT 2018


Also, I don’t think that converting JSON to XML is as simple as https://gist.github.com/sstur/7379870 in the general case.  So you may want to more fully constrain X3D JSON.  Please define the standard X3D JSON that is compatible with the previous link by all means.  We will gladly fall into your arms in relief.

John

Sent from Mail for Windows 10

From: Leonard Daly
Sent: Tuesday, March 20, 2018 11:30 AM
To: x3d-public at web3d.org
Subject: Re: [x3d-public] X3DJSONLD ... converts XML to JSON client side!

John,

I am wondering how this might differ from the following built-in capabilities described below. What does your code do differently than these built-in methods?


XD is an (string) XML fragment, then this fragment can be inserted into the DOM (either as part of the document of a separate sub-tree) using

var parser = new DOMParser();
var xmlDom = parser.parserFromString (XD, 'application/xml');

[Ref: https://developer.mozilla.org/en-US/docs/Web/API/DOMParser]

At this point xmlDom is a DOM tree, but not inserted into the HTML document DOM.

It is possible to go back to XML string using

var S = new XMLSerializer();
var xmlString = s.serializeToString (xmlDom);

[Ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLSerializer]

There is the JSON.stringify method 

[Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify and https://stackoverflow.com/questions/46880822/how-to-json-stringify-a-dom-element - answer 1]

There is at least one other GItHub project (https://gist.github.com/sstur/7379870) that converts to/from JSON and strings/DOM.

Going from an internal object to JSON takes a little careful work to make sure the tree is correctly handled and the code does not follow the circular loops that are present in DOM.


Leonard Daly



The X3D JSON Loader now converts XML to JSON client-side, for your nefarious purposes!
 
https://coderextreme.net/X3DJSONLD/src/main/html/index.html
 
Enjoy loading!
 
John



_______________________________________________
x3d-public mailing list
x3d-public at web3d.org
http://web3d.org/mailman/listinfo/x3d-public_web3d.org

-- 
Leonard Daly
3D Systems & Cloud Consultant
LA ACM SIGGRAPH Past Chair
President, Daly Realism - Creating the Future 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180320/3a1cabf3/attachment.html>


More information about the x3d-public mailing list