cheungj
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2013
03:33 PM
ParseJson does not handle negative numbers
Has anyone encountered an issue where the parsejson method when it parses out a Json integer that is a negative value it forces it as a positive value? so for example i have this json string
{test: -1} but when i run the parse json on it the value of test = 1 instead of -1?
{test: -1} but when i run the parse json on it the value of test = 1 instead of -1?
4 REPLIES 4
RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2013
04:32 PM
Re: ParseJson does not handle negative numbers
This seems to show that it works. Can you post code where it doesn't work?
--Mark
BrightScript Debugger> s="{"+chr(34)+"test"+chr(34)+": -1}"
BrightScript Debugger> ?s
{"test": -1}
BrightScript Debugger> j= ParseJSON(s)
BrightScript Debugger> ?j
test: -1
--Mark
cheungj
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2013
03:16 PM
Re: ParseJson does not handle negative numbers
jsonString = "{" + Chr(34) + "test" + Chr(34) + ":" + Stri(-1).trim() + "}"
print jsonString
print Stri(ParseJson(jsonString).test)
the first print out works and displays the right json with the negative value but after I parse and get the attribute test from the json array it returns as 1
print jsonString
print Stri(ParseJson(jsonString).test)
the first print out works and displays the right json with the negative value but after I parse and get the attribute test from the json array it returns as 1
RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2013
08:45 AM
Re: ParseJson does not handle negative numbers
This works for me. What firmware version are you running?
--Mark
--Mark
BrightScript Debugger> jsonString = "{" + Chr(34) + "test" + Chr(34) + ":" + Stri(-1).trim() + "}"
BrightScript Debugger> ?jsonString
{"test":-1}
BrightScript Debugger> print Stri(ParseJson(jsonString).test)
-1
cheungj
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2013
05:34 PM
Re: ParseJson does not handle negative numbers
5.1 in any case I did a workaround for it