How to parse json in lua? How to parse json in lua? json json

How to parse json in lua?


JSON data in that form is very close to Lua tables. So you can transform the JSON data into Lua code and run it, if you trust the JSON data.

J=[[{  "data": {    "user": {      "username": "username",      "type": "TYPE"    }  },  "passport": {    "user": "uuid"  },}]]L="return "..J:gsub('("[^"]-"):','[%1]=')T=loadstring(L)()print(T.data.user.username)

If have any qualms about the JSON data, you may want to run the string in L in a sandbox.