Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

tokkiyaa/map2json

Repository files navigation

map2json

JSON Object <=> ES6 Map Converter

Installation

npm install @tokkiyaa/map2json

Usage

ES6 Map => JSON Object

import { map2Json } from "@tokkiyaa/map2json";

const map = new Map([["a", 1], ["b", 2]]);
map2Json(map);
// {"a":1,"b":2}

JSON Object => ES6 Map

import { json2Map } from "@tokkiyaa/map2json";
const jsonObject = { a: 1, b: 2 };
json2Map(jsonObject);
// Map(2) {"a" => 1, "b" => 2}