Hey, I am switching over from JsonCpp to this library, but have run into a issue. JsonCpp had handy functions like isString(), isInt(), isDouble() and isObject() to determine the type of json value.
Previously, we would use isObject() to determine is the current value type is an object. So with the above json data, isObject would return true for component and drawable, but would return false for type (as type is a string value, not an object).
Is there some way of doing this with libjson? One way I was thinking was checking the size of each JSONNode, as the size for "type" JSONNode would return 0, however it would also return 0 for drawable, and therefore would fail the test.
I'm not sure how to get around this problem, any suggestions would be greatly appreciated!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey, I am switching over from JsonCpp to this library, but have run into a issue. JsonCpp had handy functions like isString(), isInt(), isDouble() and isObject() to determine the type of json value.
This is causing issues with the following data:
[code
]{
"type" : "parameter",
"component" : {
"name" : "sort",
"value" : 23
},
"drawable" : {}
}
Previously, we would use isObject() to determine is the current value type is an object. So with the above json data, isObject would return true for component and drawable, but would return false for type (as type is a string value, not an object).
Is there some way of doing this with libjson? One way I was thinking was checking the size of each JSONNode, as the size for "type" JSONNode would return 0, however it would also return 0 for drawable, and therefore would fail the test.
I'm not sure how to get around this problem, any suggestions would be greatly appreciated!
Ah silly me, calling type() returns if it is a JSON_STRING (which "type" is in the above json), or one of the other types such as JSON_NODE.
JSON_NODE is the object type.