{"id":19651877,"url":"https://github.com/akshitgrover/jogo","last_synced_at":"2026-04-02T01:33:40.590Z","repository":{"id":57581349,"uuid":"163584893","full_name":"akshitgrover/jogo","owner":"akshitgrover","description":"JSON o Golang | Forget static types, No more complex structure definitions, Focus on code. Go Reflect!","archived":false,"fork":false,"pushed_at":"2019-03-28T10:04:57.000Z","size":26,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-28T16:49:53.691Z","etag":null,"topics":["golang","json","reflection","static-typing"],"latest_commit_sha":null,"homepage":"","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/akshitgrover.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":"2018-12-30T12:14:55.000Z","updated_at":"2023-03-04T10:37:56.000Z","dependencies_parsed_at":"2022-09-26T19:31:04.042Z","dependency_job_id":null,"html_url":"https://github.com/akshitgrover/jogo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/akshitgrover/jogo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akshitgrover%2Fjogo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akshitgrover%2Fjogo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akshitgrover%2Fjogo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akshitgrover%2Fjogo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akshitgrover","download_url":"https://codeload.github.com/akshitgrover/jogo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akshitgrover%2Fjogo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:05:07.454Z","status":"ssl_error","status_checked_at":"2026-04-02T00:56:46.496Z","response_time":53,"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":["golang","json","reflection","static-typing"],"created_at":"2024-11-11T15:08:21.919Z","updated_at":"2026-04-02T01:33:40.569Z","avatar_url":"https://github.com/akshitgrover.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/akshitgrover/jogo/blob/master/logo.png\" alt=\"LOGO\"\u003e\n\u003cbr\u003e\u003cbr\u003e\n\u003ca href=\"http://godoc.org/github.com/akshitgrover/jogo/jogo\"\u003e\u003cimg src=\"http://godoc.org/github.com/akshitgrover/jogo/jogo?status.svg\" alt=\"LOGO\"\u003e\u003c/a\u003e\n\u003ca href=\"https://goreportcard.com/report/github.com/akshitgrover/jogo\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/akshitgrover/jogo\"\u003e\u003c/a\u003e\n\u003ca href=\"https://travis-ci.org/akshitgrover/jogo\"\u003e\u003cimg src=\"https://travis-ci.org/akshitgrover/jogo.svg?branch=master\"\u003e\u003c/a\u003e\n\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eJSON o Golang | Forget static types, No more complex structure definitions, Focus on code. Go Reflect!\u003c/b\u003e\n\u003c/p\u003e\n\nJoGO uses memoization to return results faster. JoGO facilitates handling of large and complex JSON structures by making use of go reflections and type assertions.\n\nTake a look at [benchmarks](#Benchmarks)\n\n# Installing\nType the following in **Command Line**\n\n`go get -u github.com/akshitgrover/jogo`\n\n# Usage\nImport ***JoGO*** in .go source files as follows\n\n`import \"github.com/akshitgrover/jogo/jogo\"`\n\n***Note:***\n\n***JoGO*** is distributed as a module with one package, To use ***JoGO*** package packed within the ***JoGO*** module above import path is to be used.\n\nTo find more about go modules, Read the [wiki](https://github.com/golang/go/wiki/Modules)\n\n## Export Method\n\nExport method is used to parse underlying json and return [*ExportedJson*](#ExportedJson), [*ResultJson*](#ResultJson) and [*Error*](#Error) objects.\n\n### Usage\n\n```go\npackage main\n\nimport (\n    \"github.com/akshitgrover/jogo/jogo\"\n    \"fmt\"\n)\n\nfunc main() {\n\n    exp, r, err := jogo.Export(`{\"hello\":\"world\"}`)\n    if err != nil {\n        fmt.Println(err)\n    } else {\n        fmt.Println(r.Type) // OBJECT\n        _, _ = exp.Get(\"hello\")\n    }\n\n}\n```\n\n## Get Method\n\nGet method is used to fetch value from an [*ExportedJson*](#ExportedJson) object. It returns [*ResultJson*](#ResultJson) and [*Error*](#Error) objects.\n\n```go\npackage main\n\nimport (\n    \"github.com/akshitgrover/jogo/jogo\"\n    \"fmt\"\n)\n\nfunc main() {\n\n    exp, r, err := jogo.Export(`{\"name\":{\"firstname\":\"akshit\", \"lastname\":\"grover\"}}`)\n    if err != nil {\n        fmt.Println(err)\n    } else {\n        fmt.Println(r.Type) //OBJECT\n        r2, _ := exp.Get(\"name.firstname\")\n        r3, _ := exp.Get(\"name.lastname\")\n        fmt.Println(r2.Type, r3.Type) //STRING STRING\n        fmt.Println(r2.String() + r3.String())\n    }\n\n}\n```\n\n# R method\n\nR method is used to convert any interface to ResultJson struct.\nIt accepts `interface{}` as an argument and returns `ResultJson{}`.\n\n***Note:*** R method makes it intuitive to iterate over Objects and Slices.\n\n```go\npackage main\n\nimport (\n    \"github.com/akshitgrover/jogo/jogo\"\n    \"fmt\"\n)\n\nfunc main() {\n\n    exp, r, err := jogo.Export(`{\"name\":{\"firstname\":\"akshit\", \"lastname\":\"grover\"}}`)\n    if err != nil {\n        fmt.Println(err)\n    } else {\n        fmt.Println(r.Type) //OBJECT\n        r2, _ := exp.Get(\"name\")\n        for k, v := range r2 {\n            fmt.Println(\"Key: \" + k)\n            fmt.Println(\"Value: \" + jogo.R(v).String())\n        }\n    }\n    /* Output\n\n\tOBJECT\n\tKey: firstname\n\tValue: akshit\n\t--------\n\tKey: lastname\n\tValue: grover\n\t--------\n\n\t*/\n}\n```\n\n# ExportedJson\n\nExported Json object holds parsed ***JSON***, If an underlying json represents an OBJECT (javascript alike),\n\n*{ExportedJson Object}.Get(\"{prop1}.{prop2}.{....}.{propN}\")* \n\nIs used to access any value in that json.\n\n**Any access to the value of a JSON property is to be done using ExportedJson object's Get Method.**\n\n# ResultJson\n\nGo being statically typed, Value fetched from GET method holds an underlying representation of value in the form of an interface, To convert it into a native type, Type assertion is to be used.\n\n***JoGO*** provides various method to do type assertion.\n\nResultJson object has ***Type*** attribute.\n\n## Types supported by JoGO\n\n* NUMBER\n* STRING\n* LIST\n* OBJECT\n* BOOLEAN\n\n***Note:*** Type attribute holds one of the above.\n\n## ResultJson type assertion methods\n\n* {ResultJson Object}.Int()     # Returns: int64\n* {ResultJson Object}.Float()   # Returns: float64\n* {ResultJson Object}.String()  # Returns: string \n* {ResultJson Object}.Bool()    # Returns: bool\n* {ResultJson Object}.Object()  # Returns: map[string]interface {}\n* {ResultJson Object}.List()    # Returns: []interface {}\n\n***Note:*** If underlying interface value is not the same as the one it is asserted as, go program panics.\n\nTo avoid panic state, Following methods are included.\n\nThese methods checks for interface type, If it does not match, an error is returned.\n\n* {ResultJson Object}.IntStrict()     # Returns: int64, error\n* {ResultJson Object}.FloatStrict()   # Returns: float64, error\n* {ResultJson Object}.StringStrict()  # Returns: string, error \n* {ResultJson Object}.BoolStrict()    # Returns: bool, error\n* {ResultJson Object}.ObjectStrict()  # Returns: map[string]interface {}, error\n* {ResultJson Object}.ListStrict()    # Returns: []interface {}, error\n\n***Note:*** These methods are slower than non-strict methods, It is advised to first check type using **Type** attribute then call non-strict type assert methods.\n\n## Example\n\n```go\npackage main\n\nimport (\n    \"github.com/akshitgrover/jogo/jogo\"\n    \"fmt\"\n)\n\nfunc main() {\n\n    exp, _, err := jogo.Export(`{\"name\":{\"firstname\":\"akshit\", \"lastname\":\"grover\"}}`)\n    if err != nil {\n        fmt.Println(err)\n    } else {\n        r2, _ := exp.Get(\"name.firstname\")\n        if r2.Type == \"STRING\" {\n            fmt.Println(r2.String()) //akshit\n        }\n    }\n\n}\n```\n\n# Error\n\nError object is native error interface provided by go.\n\n# Benchmarks\n\n```\nBenchmarkJoGOGet-4   \t15000000\t       317 ns/op\t      61 B/op\t       2 allocs/op\n\nBenchmarkGJSONGet-4               \t 3000000\t       475 ns/op\t       0 B/op\t   0 allocs/op\nBenchmarkGJSONGetMany4Paths-4     \t 4000000\t       470 ns/op\t      56 B/op\t   0 allocs/op\nBenchmarkGJSONGetMany8Paths-4     \t 8000000\t       463 ns/op\t      56 B/op\t   0 allocs/op\nBenchmarkGJSONGetMany16Paths-4    \t16000000\t       496 ns/op\t      56 B/op\t   0 allocs/op\nBenchmarkGJSONGetMany32Paths-4    \t32000000\t       480 ns/op\t      56 B/op\t   0 allocs/op\nBenchmarkGJSONGetMany64Paths-4    \t64000000\t       485 ns/op\t      64 B/op\t   0 allocs/op\nBenchmarkGJSONGetMany128Paths-4      128000000\t       509 ns/op\t      64 B/op\t   0 allocs/op\nBenchmarkGJSONUnmarshalMap-4      \t  900000\t      5060 ns/op\t    1920 B/op\t  26 allocs/op\nBenchmarkGJSONUnmarshalStruct-4   \t  900000\t      4984 ns/op\t     992 B/op\t   4 allocs/op\nBenchmarkJSONUnmarshalMap-4       \t  600000\t     11394 ns/op\t    2968 B/op\t  69 allocs/op\nBenchmarkJSONUnmarshalStruct-4    \t  600000\t      8674 ns/op\t     784 B/op\t   9 allocs/op\nBenchmarkJSONDecoder-4            \t  300000\t     17150 ns/op\t    4133 B/op\t 179 allocs/op\nBenchmarkFFJSONLexer-4            \t 1500000\t      3821 ns/op\t     896 B/op\t   8 allocs/op\nBenchmarkEasyJSONLexer-4          \t 3000000\t      1129 ns/op\t     501 B/op\t   5 allocs/op\nBenchmarkJSONParserGet-4          \t 3000000\t       498 ns/op\t      21 B/op\t   0 allocs/op\nBenchmarkJSONIterator-4           \t 3000000\t      1136 ns/op\t     677 B/op\t  14 allocs/op\nBenchmarkConvertNone-4            \t   50000\t     30790 ns/op\t       0 B/op\t   0 allocs/op\nBenchmarkConvertGet-4             \t   50000\t     39405 ns/op\t   49152 B/op\t   1 allocs/op\nBenchmarkConvertGetBytes-4        \t   50000\t     30780 ns/op\t      48 B/op\t   1 allocs/op\n```\n\nBenchmark testing was done on 2.3 GHz Intel Core i5, BenchMarks funcs were taken from [here](https://github.com/tidwall/gjson-benchmarks).\n\n# Copyright \u0026 License\n\n[MIT License](https://opensource.org/licenses/MIT)\n\nCopyright (c) 2018 Akshit Grover","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakshitgrover%2Fjogo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakshitgrover%2Fjogo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakshitgrover%2Fjogo/lists"}