Skip to content

louislivi/json_encode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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}

Releases

No releases published

Packages

No packages published