Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace encoding/json with github.com/buger/jsonparser #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fprimex
Copy link

@fprimex fprimex commented Jun 8, 2022

Hi. I doubt you actually want to merge this PR, so this is more of an FYI. My goal in working with ios_system and a-shell has been to get this working as a wasm binary. To achieve that I wanted to compile it with tinygo, which seems to be the easiest and most functional way to get wasm binaries with Go.

Unfortunately, encoding/json does not work with tinygo because tinygo does not have a complete implementation of reflect. It looks like that is a work in progress, but it's still a big challenge to tackle.

I found jsonparser, which appeared to both offer everything that's needed and also does not require the reflect package. It also does not need to unmarshal to a struct like other packages, which I found do not usually support map[string]interface{} as a target.

Anyway, after making these changes I can compile with:

tinygo build -no-debug -o json2csv.wasm -target wasi .

then download the wasm to a-shell's Documents/bin folder, and it works there on the iPhone / iPad just like the amd64 binary does on my iMac.

Both the amd64 and wasm versions pass go test :)

@fprimex
Copy link
Author

fprimex commented Jun 8, 2022

@fprimex
Copy link
Author

fprimex commented Jun 8, 2022

Also, I'm not sure if this is standard with go test, but I found that running go test on this project masked stderr, which would have helped me tremendously in resolving one of the test cases.

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.

1 participant