Skip to content
php json_encode javascript version.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
example.html
json_encode.js
json_encode.min.js

README.md

json_encode

php json_encode javascript version.

PHP json_encode javascript version.this file has php json_encode function ,and has php json_encode options constents

const JSON_HEX_QUOT = 8;

const JSON_HEX_TAG = 1;

const JSON_HEX_AMP = 2;

const JSON_HEX_APOS = 4;

const JSON_NUMERIC_CHECK = 32;

const JSON_UNESCAPED_SLASHES = 64;

const JSON_UNESCAPED_UNICODE = 256;

const JSON_FORCE_OBJECT = 16;

also chinese to unicode. example

中国 to \u4e2d\u56fd

- Demo

<script src="./json_encode.min.js"></script>
<script>
  var arr = new Array;
  arr['one'] = new Array;
  arr['one'][0] = 0;
  arr['one'][1] = 1;
  arr['two'] = new Array;
  arr['two']['one'] = 'one';
  arr['two']['two'] = 'two';
  arr['three'] = 3;
  console.log(json_encode(arr));
</script>
  • Result
    {"one":[0,1],"two":{"one":"one","two":"two"},"three":3}
You can’t perform that action at this time.