glideapps / glideapps/quicktype

How to get the output as object and not as a set of lines when targeting JSONSchema?

Open
#1,155 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

I am using `quicktype-core` as a library in my app.

My code looks like:
```
const qtInputData = new InputData();
const qtData = { name: 'SomeName', samples: [jsonString] }
const qtMagic = () => jsonInputForTargetLanguage(new JSONSchemaTargetLanguage(), undefined, false)
qtInputData.addSourceSync("json", qtData, qtMagic)
const qtResult = quicktypeMultiFileSync({
lang: new JSONSchemaTargetLanguage(),
inputData: qtInputData

});

const schema = combineRenderResults(qtResult).lines.join('')
```

At which point `schema` is a string and I need to `JSON.parse`. I am fairly confident that internally Quicktype has that parsed already. How can I get the JSONSchema as object directly?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.