[x3d-public] JSON Serialization to Bindings what can precision can we get?

Joseph D Williams joedwil at earthlink.net
Tue Dec 6 10:05:05 PST 2022


➢ And it's damn hard to convert an array of strings … 

Usually find a Float(string) function. 
Then there probably is a string(float) conversion.

I think this is what happened to the excess resolution feature, is that we go string to float, then that float back to string to build user code and leave the 18 decimal digits hanging on there. 

Joe

From: John Carlson
Sent: Monday, December 5, 2022 10:33 PM
To: Joe D Williams; X3D Graphics public mailing list; Humanoid Animation (H-Anim) Working Group
Subject: Re: JSON Serialization to Bindings what can precision can we get?

The hardest part is we currently convert JSON to Node.js using parseObject, we get an array of Strings.  And it's damn hard to convert an array of strings to an array of float or double. Perhaps we should look into what NodeSerializer.js does?

Too tired.  New meds are bowling me over.

I'm guessing I can improve things. adding my own type conversions in arrays.  Not now.

John

On Mon, Dec 5, 2022 at 10:27 PM John Carlson <yottzumm at gmail.com> wrote:
AFAIK, these are the suffixes we can add to double and float numbers.

Please feel free to correct, and I will update code.

Since JSON is not a binding, I have chosen not to include it. Indeed, there is no available suffix in JSON (yet) for floats and doubles.

Joe, I suggest you find a formatter for the source language in question, like printf in C.

If we can collect ways to format in various languages, we'll need some standard ways of using the formatter in the "exporter."

I've done my show for today. except for looking up formatters for JavaScript.

$ grep const.*SUFFIX *.js
CppSerializer.js:const DOUBLE_SUFFIX = '';
CppSerializer.js:const FLOAT_SUFFIX = '';
CSerializer.js:const DOUBLE_SUFFIX = '';
CSerializer.js:const FLOAT_SUFFIX = '';
JavaSerializer.js:const DOUBLE_SUFFIX = 'd';
JavaSerializer.js:const FLOAT_SUFFIX = 'f';
PythonSerializer.js:const DOUBLE_SUFFIX = '';
PythonSerializer.js:const FLOAT_SUFFIX = '';
VRMLScriptSerializer.js:const DOUBLE_SUFFIX = '';
VRMLScriptSerializer.js:const FLOAT_SUFFIX = '';

$ grep "var .*"SUFFIX *.js
DartSerializer.js:var DOUBLE_SUFFIX = '';
DartSerializer.js:var FLOAT_SUFFIX = '';
ECMAScriptSerializer.js:var DOUBLE_SUFFIX = '';
ECMAScriptSerializer.js:var FLOAT_SUFFIX = '';
JavaScriptSerializer.js:var DOUBLE_SUFFIX = '';
JavaScriptSerializer.js:var FLOAT_SUFFIX = '';
NodeSerializer.js:var DOUBLE_SUFFIX = '';
NodeSerializer.js:var FLOAT_SUFFIX = '';
X_ITESerializer.js:var DOUBLE_SUFFIX = '';
X_ITESerializer.js:var FLOAT_SUFFIX = '';

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20221206/9eb13aff/attachment.html>


More information about the x3d-public mailing list