Skip to content

Commit

Permalink
update(JS): web/javascript/reference/global_objects/json/parse
Browse files Browse the repository at this point in the history
  • Loading branch information
viperehonchuk committed Feb 3, 2025
1 parent 1b4d88b commit 63a3a09
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const jsonText = JSON.stringify(map, (key, value) =>
console.log(jsonText);
// [[1,"один"],[2,"два"],[3,"три"]]
const map2 = JSON.parse(jsonText, (key, value) =>
Array.isArray(value) ? new Map(value) : value,
Array.isArray(value) && value.every(Array.isArray) ? new Map(value) : value,
);
console.log(map2);
// Map { 1 => "один", 2 => "два", 3 => "три" }
Expand Down

0 comments on commit 63a3a09

Please sign in to comment.