Skip to content

Commit

Permalink
start root depth with 0
Browse files Browse the repository at this point in the history
  • Loading branch information
abumq committed Sep 28, 2024
1 parent 02a742e commit 465bdbd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const createObject = (obj, depth, currentKey, opts = {}) => {
const constructorName = obj.constructor.name;
if (NO_RESOLUTION_CLASS_LIST.some(f => f === constructorName)) {
if (TYPED_ARRAY_NAMES.some(f => f === constructorName)) {
return createArray(obj, 1, currentKey, opts);
return createArray(obj, 0, currentKey, opts);
}
return obj;
}
Expand Down Expand Up @@ -174,10 +174,10 @@ const json = (val, opts = {}) => {
}

if (isArrayType(val)) {
return createArray(val, 1, '<root array>', opts);
return createArray(val, 0, '<root array>', opts);
}

return createObject(val, 1, '<root>', opts);
return createObject(val, 0, '<root>', opts);
};

/**
Expand Down

0 comments on commit 465bdbd

Please sign in to comment.