Hi everyone.. any body can help me how to Pretty Print the JSON Data for easy reading?
like this:
Easy to Read

here is the json data
{"person":[{"firstName":"Clark","lastName":"Kent","job": "Reporter","roll":20},{"firstName":"Bruce","lastName":"Wayne","job":"Playboy","roll":30},{"firstName":"Peter","lastName":"Parker","job": "Photographer","roll":40}]}
what i have now is i create a for loop like this:
filter = {"{", "}", ",", "},"}
for k,v in pairs (filter) do
tFilter = String.Find(x, v, 1, false)
if v == "{" then
x = String.Replace(x, v, "{\r\n ", false);
end
if v == "}" then
x = String.Replace(x, v, "\r\n }", false);
end
if v == "," then
x = String.Replace(x, v, ",\r\n ", false);
end
if v == "}," then
x = String.Replace(x, v, "},\r\n ", false);
end
end
im my example i will find the replace all character in the table but the result not really good..
hope others can share how to acheive? thanks..
Sendai
like this:
Easy to Read

here is the json data
{"person":[{"firstName":"Clark","lastName":"Kent","job": "Reporter","roll":20},{"firstName":"Bruce","lastName":"Wayne","job":"Playboy","roll":30},{"firstName":"Peter","lastName":"Parker","job": "Photographer","roll":40}]}
what i have now is i create a for loop like this:
filter = {"{", "}", ",", "},"}
for k,v in pairs (filter) do
tFilter = String.Find(x, v, 1, false)
if v == "{" then
x = String.Replace(x, v, "{\r\n ", false);
end
if v == "}" then
x = String.Replace(x, v, "\r\n }", false);
end
if v == "," then
x = String.Replace(x, v, ",\r\n ", false);
end
if v == "}," then
x = String.Replace(x, v, "},\r\n ", false);
end
end
im my example i will find the replace all character in the table but the result not really good..
hope others can share how to acheive? thanks..
Sendai