Hello everyone,
I am currently having trouble trying to parse a JSON from a server response. Im the Client/App side programmer, and we have a Server programmer responsible for creating the JSON. So I don't really know that much about JSON and how they generate them.
I am parsing the JSON in Unity(Game Engine), using the built-in JSON Utility. I've been googling around and there might be some different variations of JSON, so I am not sure If I need a 3rd party library that can parse the specific JSON that I have.
Are you familiar with this type of JSON below?
[
{
"id": 221,
"builder_count": 1,
"units": "[{\"count\": 1, \"level\": 1, \"type_id\": 1, \"unit_id\": \"2359-1\", \"research_time\": 0, \"research_complete\": 1}],[{\"count\": 5, \"level\": 1, \"type_id\": 11, \"unit_id\": \"2359-11\", \"research_time\": 0, \"research_complete\": 1}],[{\"count\": 5, \"level\": 1, \"type_id\": 2, \"unit_id\": \"2359-2\", \"research_time\": 0, \"research_complete\": 1}]"
}
]
The Units key seems a bit off, they are being treated as a string even though they are really an object.
I have access to the server code, and this is how the Key:Units is being generated. (The whole code block is pretty big, so I just selected this part as an example, please let me know If I need to post the whole function that generated the entire JSON)
' (SELECT CAST(GROUP_CONCAT ( ' +
' JSON_ARRAY( ' +
' JSON_OBJECT( ' +
' "unit_id", tu.unique_id, ' +
' "type_id", tu.unit_type_id, ' +
' "level", tu.level, ' +
' "research_time", tu.research_time, ' +
' "research_complete", tu.research_complete, ' +
' "count", tu.tally ' +
' )' +
' )' +
' ) AS CHAR)' +
' FROM api_TurfUnits tu WHERE tu.turf_id = t.id) AS units, '
Our server technology that we use is Node.js and AWS Aurora (MySQL).
Basically I'm looking for a library that might be able to parse the type of JSON properly (the Key: Units)
I have used the website https://jsonformatter.curiousconcept.com/ and tried all the different JSON standard, but none of them can't seem to parse it.