summaryrefslogtreecommitdiff
path: root/ext/json/tests
diff options
context:
space:
mode:
authorSara Golemon <pollita@php.net>2007-12-17 07:48:27 +0000
committerSara Golemon <pollita@php.net>2007-12-17 07:48:27 +0000
commitcce03434efdb5902e0b0cb544d78bf35c550e69d (patch)
tree9e005e6e269c661566e1c33f0ac6a3388bbde9f3 /ext/json/tests
parent57189ca513d2a96c27d9062a7572f46f10eaaf34 (diff)
downloadphp-git-cce03434efdb5902e0b0cb544d78bf35c550e69d.tar.gz
MFH (json.c r-1.32) Add support for encoding options
Diffstat (limited to 'ext/json/tests')
-rw-r--r--ext/json/tests/006.phpt23
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/json/tests/006.phpt b/ext/json/tests/006.phpt
new file mode 100644
index 0000000000..e1d4b46889
--- /dev/null
+++ b/ext/json/tests/006.phpt
@@ -0,0 +1,23 @@
+--TEST--
+json_encode() & extended encoding
+--SKIPIF--
+<?php if (!extension_loaded("json")) print "skip"; ?>
+--FILE--
+<?php
+
+$a = array('<foo>',"'bar'",'"baz"','&blong&');
+
+echo "Normal: ", json_encode($a), "\n";
+echo "Tags: ", json_encode($a,JSON_HEX_TAG), "\n";
+echo "Apos: ", json_encode($a,JSON_HEX_APOS), "\n";
+echo "Quot: ", json_encode($a,JSON_HEX_QUOT), "\n";
+echo "Amp: ", json_encode($a,JSON_HEX_AMP), "\n";
+echo "All: ", json_encode($a,JSON_HEX_TAG|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_AMP), "\n";
+?>
+--EXPECT--
+Normal: ["<foo>","'bar'","\"baz\"","&blong&"]
+Tags: ["\u003Cfoo\u003E","'bar'","\"baz\"","&blong&"]
+Apos: ["<foo>","\u0027bar\u0027","\"baz\"","&blong&"]
+Quot: ["<foo>","'bar'","\u0022baz\u0022","&blong&"]
+Amp: ["<foo>","'bar'","\"baz\"","\u0026blong\u0026"]
+All: ["\u003Cfoo\u003E","\u0027bar\u0027","\u0022baz\u0022","\u0026blong\u0026"]