[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: JSON to Lua syntax converter?
- From: Petite Abeille <petite.abeille@...>
- Date: Fri, 1 Feb 2008 17:45:15 +0100
Hello,
Anyone have a JSON to Lua syntax converter in their tool bag?
Considering how close both syntax are, it should be a breeze:
[JSON]
{
"firstName": "John",
"lastName": "Smith",
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
"212 732-1234",
"646 123-4567"
]
}
[Lua]
{
[ "firstName" ] = "John",
[ "lastName" ] = "Smith",
[ "address" ] = {
[ "streetAddress" ] = "21 2nd Street",
[ "city" ] = "New York",
[ "state" ] = "NY",
[ "postalCode" ] = 10021
},
[ "phoneNumbers" ] = {
"212 732-1234",
"646 123-4567"
}
}
E.g. wrap the keys with [], change the ':' to '=', the list
delimitator to {}, null to nil and that should be pretty much it.
Then run loadstring on it or something.
Thoughts?
Cheers,
PA.