Skip to content

Conversation

@toddallen97
Copy link
Contributor

The current implementation of JSONParser does not correctly parse data not in a structure, like a single integer or float. In example:

local a = "77";
local b = JSONParser.parse(a)
server.log("Value " + b + " has type " + typeof b)

local c = http.jsondecode("77")
server.log("Value " + c + " has type " + typeof c)

Returns:

Value 77 has type string
Value 77 has type integer

I've added a few lines of code to save the last state of the state machine as to make JSONParser more consistent with http.jsondecode()'s implementation.

@betzrhodes
Copy link

Nice catch. Thank you.

@betzrhodes betzrhodes merged commit 9d7b5aa into electricimp:develop Jul 2, 2019
@toddallen97 toddallen97 changed the title Parse data not in a data structure Remove additional arguments to _convert Jul 3, 2019
@toddallen97 toddallen97 changed the title Remove additional arguments to _convert Parse data not in a data structure Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants