{"id":38798058,"url":"https://github.com/nohupped/simplejson","last_synced_at":"2026-01-17T12:44:50.354Z","repository":{"id":57511684,"uuid":"239274865","full_name":"nohupped/simplejson","owner":"nohupped","description":null,"archived":false,"fork":false,"pushed_at":"2020-03-02T03:25:07.000Z","size":51,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-12T21:23:10.442Z","etag":null,"topics":["golang","json","parser","simplejson","wrapper-library"],"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/nohupped.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":"2020-02-09T09:05:04.000Z","updated_at":"2020-03-02T03:25:06.000Z","dependencies_parsed_at":"2022-08-29T05:21:36.794Z","dependency_job_id":null,"html_url":"https://github.com/nohupped/simplejson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nohupped/simplejson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nohupped%2Fsimplejson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nohupped%2Fsimplejson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nohupped%2Fsimplejson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nohupped%2Fsimplejson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nohupped","download_url":"https://codeload.github.com/nohupped/simplejson/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nohupped%2Fsimplejson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T11:50:55.898Z","status":"ssl_error","status_checked_at":"2026-01-17T11:50:55.569Z","response_time":85,"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","parser","simplejson","wrapper-library"],"created_at":"2026-01-17T12:44:50.268Z","updated_at":"2026-01-17T12:44:50.344Z","avatar_url":"https://github.com/nohupped.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# { SimpleJSON } [![Build Status](https://travis-ci.com/nohupped/simplejson.svg?branch=master)](https://travis-ci.com/nohupped/simplejson) [![codecov.io](https://codecov.io/github/nohupped/simplejson/coverage.svg?branch=master)](https://codecov.io/github/nohupped/simplejson?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/nohupped/simplejson)](https://goreportcard.com/report/github.com/nohupped/simplejson)\n\nA lame attempt to re-create python's `json.loads()` using `Get()` methods to retrive a key by moving the ugly typeassertions to the library.\n\n## Why\n\nThis is just a wrapper over go's `encoding/json`. This uses an `interface{}` to unmarshal the json and the exposed interface method `Get()` uses `type assertions` internally to get the value of a key if it is a hashmap or the index if it is an array. Since this moves the ugly typeassertions for nested json parsing inside the library, the code becomes easier to read.\n\n## Example\n\nConsider the json string\n\n```go\nsampleJSON := `{\n    \"Actors\":\n    [\n        {\n            \"name\": \"Tom Cruise\",\n            \"age\": 56,\n            \"Born At\": \"Syracuse, NY\",\n            \"Birthdate\": \"July 3, 1962\",\n            \"hasChildren\":true,\n            \"hasTwitterAccount\":true,\n            \"hasGreyHair\":false,\n            \"photo\": \"https://jsonformatter.org/img/tom-cruise.jpg\"\n        },\n        {\n            \"name\": \"Robert Downey Jr.\",\n            \"age\": 53,\n            \"Born At\": \"New York City, NY\",\n            \"Birthdate\": \"April 4, 1965\",\n            \"photo\": \"https://jsonformatter.org/img/Robert-Downey-Jr.jpg\"\n        }\n    ]\n}`\n```\n\nThis can be parsed and values can be fetched as\n\n```go\n\nd, err := simplejson.Loads(sampleJSON)\nif err != nil {\n    panic(err)\n}\ndata := d.Get(\"Actors\").Get(\"\", 0).Get(\"name\")\nfmt.Println(data) // outputs Tom Cruise\n\n```\n\nConsider the json file `samplejson.json` in this repository.\n\nThis file can be parsed and the values can be fetched as\n\n```go\nfd, err := os.Open(\"samplejson.json\")\nif err != nil {\n    panic(err)\n}\nd1, err := Load(fd)\nif err != nil{\n    panic(err)\n}\nt.Logf(\"%s\", d1.Get(\"\", 2).Get(\"tags\").Get(\"\", 3))\n\nfd.Close()\n\n```\n\nIt is the responsibility of the caller to close the file descriptor.\n\nBecause this uses `interface{}` to unmarshal json, the structure of json is not required to be predefined. Each `Get()` evaluates the type and extracts accordingly.\n\n## `Get()` function ~~panics~~ returns `nil` for the method `Bytes()` if the key is not present\n\nInstead of returning an error, `Get()` function ~~panics~~ returns `nil` for the `Bytes()` method when trying to fetch an invalid key or trying to read from an invalid index. This is done to easily chain the method as follows\n\n```go\nGet(\"foo\").Get(\"bar\").Get(\"\", 2)\n```\n\nwithout having to evaluate for errors every time or to have to write a `recover` as below.\n\n```go\ndefer func() {\n    if r := recover(); r != nil {...}\n```\n\nEvaluate for `nil` value before using it.\n\nEg:\n\n```go\nd, err := simplejson.Loads([]byte(sampleJSON))\nif err != nil {\n    ...\n}\nd1 := d.Get(\"Actors\").Get(\"\", 0).Get(\"names\").Get(\"foo\").Get(\"Bar\")\nif d1.Bytes != nil {\n    ...\n}\n...\n\n```\n\n## `String()` function returns empty string `\"\"` for `nil` values\n\nThis is done to avoid the\n\n```bash\npanic: runtime error: invalid memory address or nil pointer dereference\n```\n\nat runtime. Evaluate for `nil` value before applying `String()` method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnohupped%2Fsimplejson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnohupped%2Fsimplejson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnohupped%2Fsimplejson/lists"}