{"id":24314945,"url":"https://github.com/karrick/goejs","last_synced_at":"2026-01-29T00:02:14.144Z","repository":{"id":57531860,"uuid":"95939197","full_name":"karrick/goejs","owner":"karrick","description":"Miniature Go library for properly encoding strings and IEEE 754 floats to JSON and back again","archived":false,"fork":false,"pushed_at":"2022-08-12T02:27:28.000Z","size":15,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-10T12:48:59.653Z","etag":null,"topics":["encoding","golang","json","serialization"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karrick.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":"2017-07-01T03:18:08.000Z","updated_at":"2019-10-23T08:51:40.000Z","dependencies_parsed_at":"2022-09-06T23:12:17.548Z","dependency_job_id":null,"html_url":"https://github.com/karrick/goejs","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/karrick/goejs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karrick%2Fgoejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karrick%2Fgoejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karrick%2Fgoejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karrick%2Fgoejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karrick","download_url":"https://codeload.github.com/karrick/goejs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karrick%2Fgoejs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28856907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T22:56:21.783Z","status":"ssl_error","status_checked_at":"2026-01-28T22:56:00.861Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["encoding","golang","json","serialization"],"created_at":"2025-01-17T10:16:16.019Z","updated_at":"2026-01-29T00:02:14.122Z","avatar_url":"https://github.com/karrick.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goejs\n\nMiniature Go library for properly encoding numbers and strings to JSON\nand back again.\n\n## Description\n\nWant to quickly serialize Go UTF-8 strings into JSON using all of the\nrelevant RFC documents? Then this library is for you.\n\nHow about round-trip encoding float values to and from JSON, including\nsupport for NaN, -Inf, and +Inf? This library also supports that.\n\nWhile the [defacto JSON website](http://json.org) only mentions a few\nrules for serializing strings into JSON, there have been several\nerrata that have been reported, and various RFC documents that seek to\nclarify some aspects of encoding values using JSON.\n\n## References\n\n* https://tools.ietf.org/html/rfc4627\n* https://tools.ietf.org/html/rfc7158\n* https://tools.ietf.org/html/rfc7159\n\n## Usage\n\nDocumentation is available via\n[![GoDoc](https://godoc.org/github.com/karrick/goejs?status.svg)](https://godoc.org/github.com/karrick/goejs).\n\nWhen encoding to JSON this library appends to a pre-existing slice of\nbytes, using the runtime to append to this slice, so it can minimize\nallocations if the byte slice capacity is already large enough to\naccomodate the encoded form of the string.\n\n```Go\nfunc ExampleFloatEncode() {\n\tencoded := goejs.AppendEncodedJSONFromFloat([]byte(\"prefix: \"), math.NaN())\n\tfmt.Printf(\"%s\", encoded)\n\t// Output: prefix: null\n}\n\nfunc ExampleStringEncode() {\n    encoded := goejs.EncodedJSONFromString([]byte(\"prefix:\"), \"\u0001⌘ a\")\n    fmt.Printf(\"%s\", encoded)\n    // Output: prefix:\"\\u0001\\u2318 a\"\n}\n```\n\nWhen decoding from JSON this library consumes bytes from an existing\nbyte slice and not only returns the decoded string but also a byte\nslice of the remaining bytes, pointed at the original byte slice's\nbacking array.\n\n```Go\nfunc ExampleFloatDecode() {\n\tdecoded, remainder, err := goejs.DecodedFloatFromJSON([]byte(\"null some extra bytes after final quote\"))\n\tif err != nil {\n\t\tfmt.Println(err)\n\t}\n\tif actual, expected := string(remainder), \" some extra bytes after final quote\"; actual != expected {\n\t\tfmt.Printf(\"Remainder Actual: %#q; Expected: %#q\\n\", actual, expected)\n\t}\n\tfmt.Printf(\"%v\", decoded)\n\t// Output: NaN\n}\n\nfunc ExampleStringDecode() {\n    decoded, remainder, err := goejs.DecodedStringFromJSON([]byte(\"\\\"\\\\u0001\\\\u2318 a\\\" some extra bytes after final quote\"))\n    if err != nil {\n        fmt.Println(err)\n    }\n    if actual, expected := string(remainder), \" some extra bytes after final quote\"; actual != expected {\n        fmt.Printf(\"Remainder Actual: %#q; Expected: %#q\\n\", actual, expected)\n    }\n    fmt.Printf(\"%#q\", decoded)\n    // Output: \"\\x01⌘ a\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarrick%2Fgoejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarrick%2Fgoejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarrick%2Fgoejs/lists"}