@@ -69,7 +69,15 @@ var_dump(Services_JSON::decode($json)); // as stdclass
6969var_dump(Services_JSON::decode($json,Services_JSON::GET_ARRAY)); // as array
7070```
7171
72- It also works (with the flag Services_JSON::DECODE_FIX_ROOT) where the string misses [ ] and {} at the start of the code
72+ #### Json unwrapped.
73+
74+ With the flag ** Services_JSON::DECODE_FIX_ROOT** , it also works when the origin text misses [ ] and {} at the start of the code.
75+ Note, this feature is not foolproof, for example "[ 1,2,3] ,[ 4,5,6] " will not wrap as "[[ 1,2,3] ,[ 4,5,6]] "
76+
77+ ```
78+ {"a":222,"b:"ccc"} # normal json
79+ "a":222,"b:"ccc" # json without the root parenthesis.
80+ ```
7381
7482``` php
7583Services_JSON::decode('1,2,3',Services_JSON::GET_ARRAY | Services_JSON::DECODE_FIX_ROOT); // returns [1,2,3]
@@ -79,6 +87,18 @@ Services_JSON::decode('"k1":"v1", k2:2',Services_JSON::GET_ARRAY | Services_JSON
7987> Note: DECODE_FIX_ROOT flag detects if the near character is ":" or ",". If the closest character is ":", then it returns
8088> an object, otherwise it returns a list. If there is none, then it returns a list.
8189
90+ #### Json with unquoted values
91+
92+ With the flag ** Services_JSON::DECODE_NO_QUOTE** it also works when the string values are not quoted.
93+
94+ > Note: invisible characters at the beginner and at the end (tabs, line carriages) will be trimmed.
95+
96+ ``` php
97+
98+ Services_JSON::decode('{"a":aaa,"b":bbbb,"c": aaaaa}'
99+ , Services_JSON::GET_ARRAY | Services_JSON::DECODE_NO_QUOTE) // ['a'=>'aaa','b'=>'bbbb','c' => 'aaaaa']
100+ ```
101+
82102
83103
84104### Encode
@@ -94,10 +114,12 @@ var_dump(Services_JSON::encode($obj)); // encode an object
94114
95115
96116## Changelog
97-
117+ * 2.3.2
118+ * Added flag to decode DECODE_NO_QUOTE
98119* 2.3.1
99120 * deleted unused code
100121 * fixed comments.
122+ * 25% of the code has been refactored.
101123* 2.3
102124 * Fixed a typo with a comment.
103125 * added phpunit. The entire code is tested but special codification.
0 commit comments