{"id":20602308,"url":"https://github.com/json-iterator/tinygo","last_synced_at":"2025-06-25T02:02:46.100Z","repository":{"id":57644086,"uuid":"433729941","full_name":"json-iterator/tinygo","owner":"json-iterator","description":"make json.Unmarshal work in tinygo","archived":false,"fork":false,"pushed_at":"2021-12-21T07:20:01.000Z","size":144,"stargazers_count":8,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-15T01:53:37.066Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/json-iterator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-01T07:42:16.000Z","updated_at":"2024-01-28T01:21:59.000Z","dependencies_parsed_at":"2022-08-30T08:01:44.205Z","dependency_job_id":null,"html_url":"https://github.com/json-iterator/tinygo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/json-iterator/tinygo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-iterator%2Ftinygo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-iterator%2Ftinygo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-iterator%2Ftinygo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-iterator%2Ftinygo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/json-iterator","download_url":"https://codeload.github.com/json-iterator/tinygo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/json-iterator%2Ftinygo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261789229,"owners_count":23209774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T09:13:24.558Z","updated_at":"2025-06-25T02:02:46.073Z","avatar_url":"https://github.com/json-iterator.png","language":"Go","readme":"# make `json.Unmarshal` work in tinygo\n\n```go\ntype NamedArray = []string\n\ntype RefNamedArray struct {\n\tValue NamedArray\n}\n\nimport \"encoding/json\"\n\nvar val1 RefNamedArray\nvar val2 NamedArray\njson.Unmarshal([]byte(`{ \"Value\": [\"hello\",\"world\"] }`), \u0026val1)\njson.Unmarshal([]byte(`[\"hello\",\"world\"]`), \u0026val2) \n```\n\nThe code above does not work in tinygo, due to incomplete runtime reflection support. To fix this, we use code generation instead of runtime reflection to implement `json.Unmarshal`\n\n```go\n//go:generate go run github.com/json-iterator/tinygo/gen\ntype NamedArray = []string\n\n//go:generate go run github.com/json-iterator/tinygo/gen\ntype RefNamedArray struct {\n\tValue NamedArray\n}\n\nimport \"github.com/json-iterator/tinygo\"\n// list all the types you need to unmarshal here\njson := jsoniter.CreateJsonAdapter(RefNamedArray_json{}, NamedArray_json{}) \n\nvar val1 RefNamedArray\nvar val2 NamedArray\njson.Unmarshal([]byte(`{ \"Value\": [\"hello\",\"world\"] }`), \u0026val1)\njson.Unmarshal([]byte(`[\"hello\",\"world\"]`), \u0026val2) \n```\n\nrun `go generate` command to generate RefNamedArray_json and NamedArray_json.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson-iterator%2Ftinygo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjson-iterator%2Ftinygo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjson-iterator%2Ftinygo/lists"}