Annotation of embedaddon/php/ext/json/tests/json_encode_pretty_print.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: json_encode() with JSON_PRETTY_PRINT
! 3: --SKIPIF--
! 4: <?php if (!extension_loaded("json")) print "skip"; ?>
! 5: --FILE--
! 6: <?php
! 7: function 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:
! 15: encode_decode('[1,2,3,[1,2,3]]');
! 16: encode_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: ]
! 29: Match: 1
! 30: {
! 31: "a": 1,
! 32: "b": [
! 33: 1,
! 34: 2
! 35: ],
! 36: "c": {
! 37: "d": 42
! 38: }
! 39: }
! 40: Match: 1
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>