Expand description
JSON re-encoding reproducing PHP’s json_encode($data, 0) applied to data
coming from json_decode($json, true) (the JsonFile::parseJson ->
JsonFile::encode pipeline, Composer 2.10.3, see docs/reference/JsonFile.php).
Byte-exact semantics:
- compact output (
{"k":v}), insertion order preserved; /escaped as\/, non-ASCII as lowercase-hex\uXXXX(surrogate pairs beyond the BMP), controls\b \f \n \r \tthen\u00XX;- assoc quirk: an empty object becomes
[], an object whose keys are exactly “0”..“n-1” in order becomes an array (PHP lost the object/array distinction at decode time); - shortest round-trip floats (serialize_precision=-1): fixed notation
without a trailing
.0for integral values (1.0->1), exponentiald[.ddd|.0]e±Xoutside (-4, 17]; seeencode_double.
Structs§
- Encode
Options - Options mirroring the json_encode flags used by Composer.
Constants§
- FLAGS_
JSONFILE - JsonFile default (files written by Composer): JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE.
- FLAGS_
ZERO - Flags 0 (content-hash): compact, slashes and unicode escaped.
- STDCLASS_
MARKER - Sentinel key: an object reduced to this key encodes as
{}(an emptystdClasson the PHP side, which the array semantics cannot express).
Functions§
- empty_
stdclass - An empty object that will encode as
{}. - php_
double smart_str_append_doublewithserialize_precision = -1: the shortest round-trip form PHP prints for a float (json_encodeandserializeshare it; the latter spells the exponentE).- php_
json_ encode - php_
json_ encode_ with