[x3d-public] MFString in python x3d.py
Vincent Marchetti
vmarchetti at kshell.com
Wed Jul 19 05:47:37 PDT 2023
> On Jul 19, 2023, at 5:40 AM, John Carlson <yottzumm at gmail.com> wrote:
>
> First off, I realize x3d.py JSON is under development.
>
> I'm trying to output an MFString to JSON in x3d.py and I'm kind of stuck? I've been modifying x3d.py to JSON output, but I've spent way too much time on it and it's dang frustrating.
>
> I have the code:
>
> ImageTexture(url=["images/X3dJavaSceneAccessInterfaceSaiLibrary.png","http://www.web3d.org/specifications/java/examples/images/X3dJavaSceneAccessInterfaceSaiLibrary.png"])
>
> Don has:
>
> ImageTexture(url=["images/X3dJavaSceneAccessInterfaceSaiLibrary.png","http://www.web3d.org/specifications/java/examples/images/X3dJavaSceneAccessInterfaceSaiLibrary.png"])
>
Yes, those two declarations of the ImageTexture node are the same.
Can you show what the resulting json encoding of this node is, and what problems are occurring with that encoding?
> The same, right?
>
> I'm wondering if I should try this approach:
>
> NavigationInfo(type="\"EXAMINE\" \"FLY\" \"ANY\""),
>
I would recommend against this.
This approach is mixing up the details of several different encodings at once.
The expression you have there, in particular the \" constructions, is going to be interpreted according to the rules of the Python Lexical parser https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals
and, if done just right, gives you the single python string with value
"EXAMINE""FLY""ANY"
This string only works as to represent an MFString value, when used to form an XML attribute in the XML encoding of X3D. It has little to do with json.
> John
>
Vince Marchetti
More information about the x3d-public
mailing list