Skip to content
Aierse edited this page Oct 17, 2023 · 2 revisions

JSON makes flat

import JSONExtend from "@aierse/json-extend";

const json = {
  required: {
    id: "test",
    password: "test"
  },
  notRequired: {
    phone: "010-1234-5678",
    memo: "",
    etc: undefined
  },
}

// JSON makes flat
json = JSONExtend.flat(json)
/*
{
    id: "test",
    password: "test",
    phone: "010-1234-5678",
    memo: "",
    etc: undefined
}

Clone this wiki locally