Groups
Groups
Sign in
Groups
Groups
Ajax.org Cloud9 Editor (Ace)
Conversations
About
Send feedback
Help
format json
809 views
Skip to first unread message
sym3tri
unread,
May 16, 2012, 6:58:35 PM
5/16/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ace-d...@googlegroups.com
Does functionality exist to format JSON conent?
I didn't see anything in the API docs.
I'm looking for a function like...
editor.format()
or
editor.formatJson()
or something similar.
thanks.
Harutyun Amirjanyan
unread,
May 17, 2012, 2:56:36 AM
5/17/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ace-d...@googlegroups.com
no
but if you need it only for valid json you can just do
JSON.stringify(JSON.parse(str), null, 4)
for formatting broken json or js use jsBeautify instead
(
https://github.com/einars/js-beautify
it even works for html and css)
see
https://github.com/MikeRatcliffe/Acebug/blob/master/chrome/content/ace++/startup.js#L369-414
for an example
sym3tri
unread,
May 17, 2012, 5:26:52 PM
5/17/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ace-d...@googlegroups.com
Awesome. Thanks!
I never noticed the extra optional arguments in JSON.stringify.
Reply all
Reply to author
Forward
0 new messages