Skip to content

Commit

Permalink
Added nest
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Dec 9, 2024
1 parent 0cf8387 commit b857c5d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/common/JsonGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,32 @@ export default class JsonGenerator {
yield `{${nest}"$id": ${$id}`;
for (const key in model) {
if (Object.prototype.hasOwnProperty.call(model, key)) {
yield ",";
const element = model[key];
if (element === void 0) {
continue;
}
yield ",";
if (nest) {
yield nest;
}
yield JSON.stringify(key);
yield `:`;
if (element === null) {
yield "null";
continue;
}
switch(typeof element) {
case "bigint":
yield JSON.stringify(element.toString());
continue;
case "boolean":
yield element ? "true": "false";
continue;
case "string":
case "number":
yield JSON.stringify(element);
continue;
}
yield this.recursiveGenerate(element, doneMap);
}
}
Expand Down

0 comments on commit b857c5d

Please sign in to comment.