1--TEST-- 2json_encode() with JSON_PRETTY_PRINT 3--SKIPIF-- 4<?php if (!extension_loaded("json")) print "skip"; ?> 5--FILE-- 6<?php 7function encode_decode($json) { 8 $struct = json_decode($json); 9 $pretty = json_encode($struct, JSON_PRETTY_PRINT); 10 echo "$pretty\n"; 11 $pretty = json_decode($pretty); 12 printf("Match: %d\n", $pretty == $struct); 13} 14 15encode_decode('[1,2,3,[1,2,3]]'); 16encode_decode('{"a":1,"b":[1,2],"c":{"d":42}}'); 17?> 18--EXPECT-- 19[ 20 1, 21 2, 22 3, 23 [ 24 1, 25 2, 26 3 27 ] 28] 29Match: 1 30{ 31 "a": 1, 32 "b": [ 33 1, 34 2 35 ], 36 "c": { 37 "d": 42 38 } 39} 40Match: 1 41