// { type: "num", desc: "查询类型 0:查询全部(不传时默认),1:查询充值可用币种,2:查询提现可用币种", required: true, } import ncp from "copy-paste"; import { IParamsType } from "./base/interface"; import DocUtil from "./utils/docUtill"; let res = ncp.paste(); console.log(JSON, res); console.log(JSON.parse(res)); let obj = JSON.parse(res); let result: Record = {}; Object.entries(obj).forEach(p => { let required = p != null; let type = !required ? null : typeof (p[1]) as any; if (type === "string") { type = DocUtil.firstUpper(type); } result[p[0]] = { required, type, desc: "" }; if (required === true) { delete result[p[0]].required; } }) console.log(333, result);