Format Json with TextWrangler

Format Json with TextWranglerFatih ÜstündağBlockedUnblockFollowFollowingJan 20, 2017Format Json with TextWranglerI use TextWrangler on my Mac as a text editor.

TextWrangler has a feature called “Text Filter” you can run some custom filters on text file.

I need format xml and json strings sometimes.

While googling, I found xml filter for TextWrangler.

Then, I write json filter with php same as xml filterOpen TextWrangler and new fileCopy and paste the code below#!/usr/bin/php<?php$inputStr = '';while (false !== ($line = fgets(STDIN))) { $inputStr .

= $line;}$jsonStr = json_decode($inputStr);if ($jsonStr) { echo json_encode($jsonStr, JSON_PRETTY_PRINT);} else { echo $inputStr;}Save the file, something like tidyJson.

php, in the ~/Library/Application Support/TextWrangler/Text Filters/ folder.

You can use json filter and format json texts.

.

. More details

Leave a Reply