scottybwoy Posted January 11, 2008 Share Posted January 11, 2008 Hi REGEX Lords, I'd like to beautify my JSON files so it's a bit easier to read. json_encode and fwrite, just sticks it all on on line, so I'd like to add in some /n and /t to break it up a bit. So I thought once I've got my JSON encoded object I could use some preg_replace magic to do some stuff like changing { => {/n/t } => }/n : => " : " // But without the quotes, just wanted to space it out a bit , => ,/n // and would it be possible to have the cursor level to the line above it? Thanks for your help, this may be a good one to put up on some Regex libraries too, what do ya think Quote Link to comment Share on other sites More sharing options...
dsaba Posted January 11, 2008 Share Posted January 11, 2008 From the sample data you provided that consisted of about 1 character each, nothing was beside them. Simply using str_replace() should do the trick. Oh maybe there are situations where str_replace() would replace unwanted things, well provide a better example then. Because not everyone is so familiar with JSON to know what you mean. Duh? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.