mirror of
https://github.com/flynx/serialize.js.git
synced 2026-07-10 11:10:57 +00:00
minor tweaks and fixes....
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9227dc0570
commit
6bc6d7cd53
@ -51,12 +51,12 @@ Thus, care must be taken when serializing structures containing function.
|
|||||||
|
|
||||||
## Format
|
## Format
|
||||||
|
|
||||||
The output of `.serialize(..)` is a strict superset of standard JSON,
|
The output of `.serialize(..)` is a strict superset of [standard JSON](https://www.json.org/json-en.html),
|
||||||
while the input format is a bit more relaxed than in several details.
|
while the input format is a bit more relaxed than in several details.
|
||||||
|
|
||||||
Extensions to JSON:
|
Extensions to JSON:
|
||||||
- Recursion
|
- Recursion
|
||||||
- null types
|
- undefined / NaN
|
||||||
- BigInt
|
- BigInt
|
||||||
- Map / Set
|
- Map / Set
|
||||||
- Function
|
- Function
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-serialize",
|
"name": "ig-serialize",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"description": "experimental extended json serializaion...",
|
"description": "experimental extended json serializaion...",
|
||||||
"main": "serialize.js",
|
"main": "serialize.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
* position?
|
* position?
|
||||||
* (XXX move this note to diff.jx)
|
* (XXX move this note to diff.jx)
|
||||||
*
|
*
|
||||||
|
* XXX do a revision of the JSON standard for things I could have forgotten...
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
@ -267,7 +268,7 @@ module.eJSON = {
|
|||||||
|
|
||||||
0: 'number', 1: 'number', 2: 'number', 3: 'number', 4: 'number',
|
0: 'number', 1: 'number', 2: 'number', 3: 'number', 4: 'number',
|
||||||
5: 'number', 6: 'number', 7: 'number', 8: 'number', 9: 'number',
|
5: 'number', 6: 'number', 7: 'number', 8: 'number', 9: 'number',
|
||||||
'.': 'number', '-': 'number',
|
'.': 'number', '-': 'number', '+': 'number',
|
||||||
|
|
||||||
'[': 'array',
|
'[': 'array',
|
||||||
'{': 'object',
|
'{': 'object',
|
||||||
@ -410,8 +411,11 @@ module.eJSON = {
|
|||||||
var j = i+1
|
var j = i+1
|
||||||
while(j < str.length
|
while(j < str.length
|
||||||
&& (str[j] == '.'
|
&& (str[j] == '.'
|
||||||
|
|| str[j] == 'e'
|
||||||
|| (str[j] >= '0'
|
|| (str[j] >= '0'
|
||||||
&& str[j] <= '9'))){
|
&& str[j] <= '9'))){
|
||||||
|
if(str.slice(j, j+2) == 'e+'){
|
||||||
|
j++ }
|
||||||
j++ }
|
j++ }
|
||||||
// BigInt...
|
// BigInt...
|
||||||
if(str[j] == 'n'){
|
if(str[j] == 'n'){
|
||||||
|
|||||||
6
test.js
6
test.js
@ -45,6 +45,10 @@ var setups = test.Setups({
|
|||||||
return ['123', json] },
|
return ['123', json] },
|
||||||
'number-neg': function(assert){
|
'number-neg': function(assert){
|
||||||
return ['-123', json] },
|
return ['-123', json] },
|
||||||
|
//'number-pos': function(assert){
|
||||||
|
// return ['+123', json] },
|
||||||
|
'number-exp': function(assert){
|
||||||
|
return ['1e+100', json] },
|
||||||
'number-zero': function(assert){
|
'number-zero': function(assert){
|
||||||
return ['0', json] },
|
return ['0', json] },
|
||||||
'float-a': function(assert){
|
'float-a': function(assert){
|
||||||
@ -196,6 +200,8 @@ test.Cases({
|
|||||||
// numbers/floats...
|
// numbers/floats...
|
||||||
['.123', '0.123'],
|
['.123', '0.123'],
|
||||||
['123.', '123'],
|
['123.', '123'],
|
||||||
|
['+123', '123'],
|
||||||
|
['123e100', '123e+100'],
|
||||||
|
|
||||||
// string quotes...
|
// string quotes...
|
||||||
["'abc'", '"abc"'],
|
["'abc'", '"abc"'],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user