I am writing a test function that can parse a string into tables. Here is the test string:
{"part A": [{"id":2264,"name":"My Tank","uniqueId":"014682003358115"}],"Part B" :[{"id":32,"attributes":{"adc":"0","raw":"0","cid":"89302750000000044889","distance":6277.98,"land":"SE-8-45-3-W2","ip":"193.181.246.215"},"deviceId":2264,
"portName":"demo test ca","portNumber":1}]}
What i want as result is something like this:
Part A:
id:2264
name: "My tank"
....etc
Part B:
id: 32
attribute: (here is a sub table where element is belong to attribute)
adc: 0
.....etc
I looked for split join in lua document but it doesnt answer as how to put the table and sub table.
I am thinking of something simple like this:
function ParseString(s, delimiter)
local result = {}
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match)
end
return result
end
but it wont work for multiple delimeter like in this string