Refactor of export to JSON function #175
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problems I wanted to address that are present with current implementation:
How I fixed them:
I split logic to 2 parts, one is a new Mapper that traverse the tree and simplifies it and only after that simplified object is mapped to a JSON string. This allows us to control how we want the final object to look like before it is mapped to JSON, but now we can also add exports to new formats without a need to copy/paste tree traversing.
One thing I wanted to ask: Was it somehow required for Uint8Byte arrays to be truncated to 64 elements? I left that part "as is", but we would change it would make it possible to have the whole structure of the object as it is represented in the tree: so users could export raw JSON directly to their projects without a need to generate the parser and load a file again afterwards. It would also fix this issue:
#147