logo
down
shadow

Display json in a readable format in a new tab


Display json in a readable format in a new tab

By : Mohamed Adel - Devel
Date : November 19 2020, 03:59 PM
this will help Put it into a pre tag, and it will keep the whitespace during display. Your code changed a bit:
code :
    var myjson = JSON.stringify(json, null, 2);
    console.log(myjson);
    var x = window.open();
    x.document.open();
    x.document.write('<html><body><pre>' + myjson + '</pre></body></html>');
    x.document.close();


Share : facebook icon twitter icon
Convert Json Javascript format to PHP readable format

Convert Json Javascript format to PHP readable format


By : Ajay Tv
Date : March 29 2020, 07:55 AM
This might help you I have bunch of json files to read through and store some information to db using PHP. , Here is my solution to your problem. Yeah it is regex but it works.
code :
$text = preg_replace(["/\\\\'/", '/("(.*?)"|(\w+))(\s*:\s*(".*?"|.))/s'], ["'", '"$2$3"$4'], $text);
$text = json_decode($text);
$text = preg_replace(["/\\\\'/", '/("(.*?)"|(\w+))(\s*:\s*(".*?"|.))/s', '/((:\s*)(0\d+))/'], ["'", '"$2$3"$4', '$2"$3"'], $text);
Format JSON string using js/jquery to readable format in textarea

Format JSON string using js/jquery to readable format in textarea


By : onthecodepath
Date : March 29 2020, 07:55 AM
should help you out I have a js variable that contains an object. I'm passing the data in that object to a html