Pretty Print JSON Structure

Aquí puedes preguntar o compartir tus dudas y conocimientos acerca del programa
Hi everyone.. any body can help me how to Pretty Print the JSON Data for easy reading?

like this:

Easy to Read

Imagen


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
here is the clean solutions i figure out:

fil = {"{", "}", ",", "},"}
rep = {"{\r\n ", "\r\n }", ",\r\n ", "},\r\n "}

for k,v in pairs (fil) do
x = String.Replace(x, v, rep[k], false);
end

Thanks hope it helps...