GetJSONRaw(JSONValue)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

GetJSONRaw(JSONValue)

Post 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
Simon White
dCipher Computing
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: GetJSONRaw(JSONValue)

Post 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.
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

Re: GetJSONRaw(JSONValue)

Post by swhite »

Yes extending GetJSONString() would definitely work. I just thought that a new function would better ensure no backward compatibility issues.

Simon
Simon White
dCipher Computing
User avatar
the.weavster
Addict
Addict
Posts: 1537
Joined: Thu Jul 03, 2003 6:53 pm
Location: England

Re: GetJSONRaw(JSONValue)

Post by the.weavster »

+1
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: GetJSONRaw(JSONValue)

Post by davido »

Whichever is deemed best...
+1
DE AA EB
Post Reply