Page 1 of 1

GetJSONRaw(JSONValue)

Posted: Thu Sep 09, 2021 7:18 pm
by swhite
Hi

I would like to suggest a new JSON function:

Result$ = GetJSONRaw(JSONVALUE)

This would be useful in deciding how numeric values should be handled. If Result$ = "13.0" then you could convert the value to a double. If the Result$ = "13" you could convert the number to an integer.

Simon

Re: GetJSONRaw(JSONValue)

Posted: Fri Sep 10, 2021 4:17 am
by kenmo
+1
but with a slight suggestion

Really your request is for numbers, right? Like for the value 13, you want the original "13.000" as it's written.

That's not useful for the other JSON types: null is always "null", boolean is always "true" or "false", string is already a string, object and array are container structures.

So I suggest: instead of adding a new function, just extend GetJSONString() to accept JSON nodes of type "number" too, to return its original string. Simple, IMHO.

Re: GetJSONRaw(JSONValue)

Posted: Fri Sep 10, 2021 2:24 pm
by swhite
Yes extending GetJSONString() would definitely work. I just thought that a new function would better ensure no backward compatibility issues.

Simon

Re: GetJSONRaw(JSONValue)

Posted: Sat Sep 11, 2021 11:02 am
by the.weavster
+1

Re: GetJSONRaw(JSONValue)

Posted: Sat Sep 11, 2021 7:02 pm
by davido
Whichever is deemed best...
+1