Skip to content

How to extract brief JSON representation of a type? #1225

Answered by ssalbdivad
gabrielgrant asked this question in Q&A
Discussion options

You must be logged in to vote

Eventually, I'd like to be able to generate a canonical definition from an arbitrary type. Would also be happy to accept contributions on this feature:

#818

That said, this kind of definition would be optimized for visual clarity when printed (like the string), but would not be traversable at all (containing unparsed strings etc.). Being able to recreate a def from an arbitrary node would be useful in some cases to pass back into ArkType, especially for testing, but I'd expect its utility to be fairly limited externally?

Alternatively, you could use toJsonSchema if you want a familiar representation, although it wouldn't be guaranteed to be less verbose.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@gabrielgrant
Comment options

Answer selected by gabrielgrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants