[x3d-public] DOM2JSONSerializer.js (and X3DJSONLD.js)

John Carlson yottzumm at gmail.com
Tue Mar 6 09:24:12 PST 2018


It's not that JSON doesn't have container fields.   It's just that they're
probably called field labels and start with a -.

John

On Mar 6, 2018 12:09 PM, "Andreas Plesch" <andreasplesch at gmail.com> wrote:

> On Tue, Mar 6, 2018 at 10:46 AM, Andreas Plesch <andreasplesch at gmail.com>
> wrote:
> > On Mon, Mar 5, 2018 at 5:25 PM, John Carlson <yottzumm at gmail.com> wrote:
> >> I have at least one more task on DOM2JSONSerializer.js.  I need to
> identify
> >> ...
> >> Time for me to think on this.   What cases should containerField get
> filled
> >> in in the DOM?  I have been trying to minimize them, but it shot me in
> the
> >> foot, so now I’m tending to maximize it.
> >
> > Here is what I understand about containerfield, probably incompletely:
> >
> > From looking at the JSON schema, it appears that json encoding does
> > not need a containerfield property for any node.
> > This means that it is generally impossible to have an exact roundtrip
> > XML/DOM-JSON-XML/DOM if XML/DOM has unnecessary containerfield
> > attributes since those will not be preserved in the json structure.
> > It is possible to have functional roundtrips, however.
> >
> > For JSON -> XML/DOM it should be ok to just always provide a
> > containerfield. It may slow down DOM parsing in some X3D browsers, and
> > leads to verbose XML when serialized.
> > Perhaps the only comprehensive way to then omit unnecessary
> > containerfield atttributes is to use the XML schema to assemble a list
> > of default containerfield values for each x3d node which would take
> > some time to learn how to do but is a one time effort. x_ite has a
> > .getContainerField() method for each node which returns the default
> > containerField.
> > It should also be possible to generate the limited set of nodes which
> > can have children which potentially need containerField, or the set of
> > nodes which never need containerfield in their children. Perhaps such
> > a list already exists ?
>
> Digging found this list of nodes:
>
> http://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html#
> containerField
>
> which is what I had in mind.
>
> I think grouping nodes may also need to be listed since their xml
> children may either be values of their children field (the default) or
> the value of their SFNode metadata field.
>
> -Andreas
>
>
> >
> > -Andreas
> >
> >
> >
> >>
> >>
> >>
> >> John
> >>
> >>
> >>
> >> Sent from Mail for Windows 10
> >>
> >>
> >>
> >> From: John Carlson
> >> Sent: Monday, March 5, 2018 1:22 PM
> >> To: Andreas Plesch
> >> Cc: Holger Seelig; X3D Graphics public mailing list; Don Brutzman
> >> Subject: Re: Effects of scrunching all VRMLscript in a Script into a
> >> singleline, X_ITE.
> >>
> >>
> >>
> >> Thanks for your explanation, Andreas.  It looks like I should proceed
> with
> >> good speed at coming up with a replacement for X3dToJson.xslt.    which
> is
> >> almost complete, if someone wants to help...
> >>
> >>
> >>
> >> https://github.com/coderextreme/X3DJSONLD/blob/master/src/main/node/
> DOM2JSONSerializer.js
> >>
> >>
> >>
> >> One of the last tasks is identifying which arrays should be objects.
> >>
> >>
> >>
> >> John
> >>
> >>
> >>
> >> On Mar 5, 2018 12:57 PM, "Andreas Plesch" <andreasplesch at gmail.com>
> wrote:
> >>
> >> One (fatal) issue with just merging all lines into a single line are
> >> caused by ecmascript single line comments:
> >>
> >> // helpful explanation
> >> var radius1 = outerRadius - toothDepth / 2;
> >> ...
> >>
> >> versus
> >>
> >> // helpful explanation var radius1 = outerRadius - toothDepth / 2; ...
> >>
> >> which never evaluates radius1.
> >>
> >> If all comments would be replaced by multiline commenting  as in /*
> >> helpful explanation */ , the single script line may work (if all lines
> >> are carefully terminated by semicolons which is not required in many
> >> situations in ecmascript:
> >> https://developer.mozilla.org/en-US/docs/Web/JavaScript/
> Reference/Lexical_grammar#Automatic_semicolon_insertion
> >> ,
> >> https://www.theregister.co.uk/2018/01/12/javascript_
> technical_group_semicolons/).
> >>
> >> It is definitely safest (and probably unavoidable) to preserve line
> >> breaks in the json.
> >>
> >> X_ITE itself cannot really do much more than eval the provided script
> as is.
> >>
> >> -Andreas
> >>
> >>
> >>
> >>
> >> On Mon, Mar 5, 2018 at 11:23 AM, John Carlson <yottzumm at gmail.com>
> wrote:
> >>> Holger, can you look at X_ITE to see the effect of scrunching all the
> >>> VRMLScript in a Script into a single line?  I’m having issues with that
> >>> right now, with JSON.  Thanks!
> >>>
> >>>
> >>>
> >>> John
> >>
> >>
> >>
> >> --
> >> Andreas Plesch
> >> Waltham, MA 02453
> >>
> >>
> >
> >
> >
> > --
> > Andreas Plesch
> > Waltham, MA 02453
>
>
>
> --
> Andreas Plesch
> Waltham, MA 02453
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180306/053b4a94/attachment.html>


More information about the x3d-public mailing list