minor tweaks and fixes....

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2026-01-11 03:51:26 +03:00
parent 9227dc0570
commit 6bc6d7cd53
4 changed files with 14 additions and 4 deletions

View File

@ -51,12 +51,12 @@ Thus, care must be taken when serializing structures containing function.
## 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.
Extensions to JSON:
- Recursion
- null types
- undefined / NaN
- BigInt
- Map / Set
- Function

View File

@ -1,6 +1,6 @@
{
"name": "ig-serialize",
"version": "1.0.4",
"version": "1.0.5",
"description": "experimental extended json serializaion...",
"main": "serialize.js",
"scripts": {

View File

@ -35,6 +35,7 @@
* position?
* (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',
5: 'number', 6: 'number', 7: 'number', 8: 'number', 9: 'number',
'.': 'number', '-': 'number',
'.': 'number', '-': 'number', '+': 'number',
'[': 'array',
'{': 'object',
@ -410,8 +411,11 @@ module.eJSON = {
var j = i+1
while(j < str.length
&& (str[j] == '.'
|| str[j] == 'e'
|| (str[j] >= '0'
&& str[j] <= '9'))){
if(str.slice(j, j+2) == 'e+'){
j++ }
j++ }
// BigInt...
if(str[j] == 'n'){

View File

@ -45,6 +45,10 @@ var setups = test.Setups({
return ['123', json] },
'number-neg': function(assert){
return ['-123', json] },
//'number-pos': function(assert){
// return ['+123', json] },
'number-exp': function(assert){
return ['1e+100', json] },
'number-zero': function(assert){
return ['0', json] },
'float-a': function(assert){
@ -196,6 +200,8 @@ test.Cases({
// numbers/floats...
['.123', '0.123'],
['123.', '123'],
['+123', '123'],
['123e100', '123e+100'],
// string quotes...
["'abc'", '"abc"'],