Support Stringify-ed JSON
If the pasted content is a valid result of (JSON.stringify), (ie, JSON.parse(contents) is valid), then show the resulting JSON in the preview
If the pasted content is a valid result of (JSON.stringify), (ie, JSON.parse(contents) is valid), then show the resulting JSON in the preview
Log in to comment and vote
Comments4
@levelsio
Dec 12, 2024
I’m confused cause that’s exactly what it already does. It converts JSON strings into explorable trees
Azure Leaf
Dec 13, 2024
Ok, looks like I was running into a different issue, and thought it was a string issue:
json.pub doesn’t support top-level JSON array, which is legal.
Ex: [{"a":1},{"b":2},{"c":3}]
https://json.pub/#d=NobwRAhmBcCMC%2BAacAjGAmJ4DGMDM8AukA
It does work with stringifyed/escaped strings as confirmed here:
https://json.pub/#d=EQbwOsCGEFwQLgUwM7wgX2EA
Edit. Hm I’m sometimes able to get top-level arrays to work if I do “copy object” from the console & paste it in. Here are some sample strings that don’t work for me:
// example 1 "[{\"title\":\"My title\",\"items\":[{\"name\":\"item 1\",\"type\":\"cool item\"}]}]" // example 2 [{"title":"My title","items":[{"name":"item 1","type":"cool item"}]}]Azure Leaf
Dec 13, 2024
2nd example works once i add a space after the first
[https://json.pub/#d=NobwRALglhA2CmYBcYCyBPABNOiA0YM8AtgM7KhgB2AhsYikcZgIxgEToAODYAxgHsBsTEzABfALpSAUEA
vs
https://json.pub/#d=NoKA3gRALgllA2BTCAuCBZAngAlg5ANBHIgLYDOqwkAdgIanJomnYCMERUmADkxAGMA9kPjYWEAL4BdGSCA
@levelsio
Dec 30, 2024
Both work now!