Skip to content

Conversation

@aykevl
Copy link
Member

@aykevl aykevl commented Mar 24, 2021

This PR adds initial support for the encoding/json package. It is far from complete (structs don't work yet, for example) but it seems to actually work for encoding some trivial types.

aykevl added 4 commits March 24, 2021 16:22
They both reversed the direction of the check, in a way that mostly
cancelled each other out. Of course they're still mostly unimplemented,
but it's better if they're not wrong.
This is important as golden test output and to verify that the output is
correct. Later improvements and bug fixes are clearly visible in the IR,
and unintentional changes will also be immediately spotted.
This is required for correctly differentiating between interface types.
This commit adds a new transform that converts reflect Implements()
calls to runtime.interfaceImplements. At the moment, the Implements()
method is not yet implemented (how ironic) but if the value passed to
Implements is known at compile time the method call can be optimized to
runtime.interfaceImplements to make it a regular interface assert.

This commit is the last change necessary to add basic support for the
encoding/json package. The json package is certainly not yet fully
supported, but some trivial objects can be converted to JSON.
@deadprogram
Copy link
Member

Still much to be done, but a most impressive step forward, and with the unit tests to prove it. Good work @aykevl

Now merging.

@deadprogram deadprogram merged commit bcce296 into dev Mar 28, 2021
@deadprogram deadprogram deleted the json-2 branch March 28, 2021 12:00
@atdiar
Copy link

atdiar commented Mar 31, 2021

Does tinygo support the use of encoding/json for unmarshalling json formatted data into the basic go types (besides custom structs) now?
I need to unmarshal into map[string]interface{}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants