{"id":13413256,"url":"https://github.com/limiu82214/gojmapr","last_synced_at":"2026-01-17T17:03:50.751Z","repository":{"id":151933825,"uuid":"623498965","full_name":"limiu82214/gojmapr","owner":"limiu82214","description":"get simple struct from complex json","archived":false,"fork":false,"pushed_at":"2023-06-21T02:59:07.000Z","size":34,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-22T13:32:03.753Z","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/limiu82214.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-04-04T13:47:00.000Z","updated_at":"2024-01-12T02:17:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"f2763e85-4749-4197-8e2b-52053231b0b0","html_url":"https://github.com/limiu82214/gojmapr","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/limiu82214/gojmapr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limiu82214%2Fgojmapr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limiu82214%2Fgojmapr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limiu82214%2Fgojmapr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limiu82214%2Fgojmapr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/limiu82214","download_url":"https://codeload.github.com/limiu82214/gojmapr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/limiu82214%2Fgojmapr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: 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":[],"created_at":"2024-07-30T20:01:36.220Z","updated_at":"2026-01-17T17:03:50.726Z","avatar_url":"https://github.com/limiu82214.png","language":"Go","funding_links":[],"categories":["JSON"],"sub_categories":["Search and Analytic Databases","检索及分析资料库"],"readme":"# gojmapr\n\n![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/limiu82214/gojmapr?label=version) [![Go Reference](https://pkg.go.dev/badge/github.com/limiu82214/gojmapr.svg)](https://pkg.go.dev/github.com/limiu82214/gojmapr) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![codecov](https://codecov.io/gh/limiu82214/gojmapr/branch/master/graph/badge.svg?token=QX59JZM663)](https://codecov.io/gh/limiu82214/gojmapr) [![Go Report Card](https://goreportcard.com/badge/github.com/limiu82214/gojmapr)](https://goreportcard.com/report/github.com/limiu82214/gojmapr) ![github actions workflow](https://github.com/limiu82214/gojmapr/actions/workflows/lint.yml/badge.svg) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)  \n\n\n[中文版文檔](./README_ZH.md)\n\ngojmapr is a Golang library that allows for quick extraction of specified properties from complex JSON strings and converts them into corresponding Go structures.\n\nWith gojmapr, you don't need to declare a complete Go structure that corresponds to the entire JSON structure, just provide the required properties.\n\nThis makes gojmapr particularly useful for extracting specific data when accessing third-party resources, making your code more concise and readable.\n\n## Features\n\nEasy to use: Easily extract required properties from JSON strings by adding a few tags.\nSupports nested properties: Easily extract required properties from JSON strings with multiple nested levels.\n\n## Installation\n\nTo use gojmapr, first add it to your Golang project:\n\n```go\ngo get github.com/limiu82214/gojmapr\n```\n\n## Usage\n\nTo use the gojmapr library, simply import it into your code and follow these steps:\n\nDefine a struct that corresponds to the JSON string you want to parse.\nAdd the gojmapr tag to each property in the struct to specify the path to extract the property from the JSON string (reference jpath).\nUse the gojmapr.Unmarshal function to parse the JSON string into a struct object.\n\n## Example\n\nHere's a simple example that shows how to use the gojmapr library to extract properties from a JSON string.\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/limiu82214/gojmapr\"\n)\n\nfunc main() {\n    jsonString := `{\n        \"user\": {\n            \"name\": \"John\",\n            \"email\": \"john@example.com\"\n        },\n        \"cart\": {\n            \"items\": [\n                {\n                    \"product\": {\n                        \"id\": \"123\",\n                        \"name\": \"Product A\",\n                        \"description\": \"Product A description\",\n                        \"price\": 10.99\n                    },\n                    \"quantity\": 2\n                },\n                {\n                    \"product\": {\n                        \"id\": \"456\",\n                        \"name\": \"Product B\",\n                        \"description\": \"Product B description\",\n                        \"price\": 5.99\n                    },\n                    \"quantity\": 1\n                }\n            ],\n            \"total\": 27.97\n        },\n        \"shipping\": {\n            \"method\": \"standard\",\n            \"address\": {\n                \"street\": \"123 Main St\",\n                \"city\": \"Anytown\",\n                \"state\": \"CA\",\n                \"zip\": \"12345\"\n            },\n            \"fee\": 5.99\n        },\n        \"create_at\": \"2020-01-01T00:00:00Z\"\n    }`\n\n    type tmpStruct struct {\n        Name string `gojmapr:\"user.name\"`\n    }\n\n    var s tmpStruct\n    err := gojmapr.Unmarshal([]byte(jsonString), \u0026s)\n    if err != nil {\n        panic(err)\n    }\n\n    fmt.Println(s.Name) // Output: John\n\n    type tmpStruct2 struct {\n        ID    string  `gojmapr:\"$.cart.items[0].product.id\"`\n        Price float64 `gojmapr:\"$.cart.items.0.product.price\"`\n    }\n\n    var s2 tmpStruct\n    err := Unmarshal([]byte(jsonString), \u0026s2)\n    if err != nil {\n        panic(err)\n    }\n\n    fmt.Println(s2.ID) // Output: 123\n    fmt.Println(s2.Price) // Output: 10.99\n}\n```\n\nMore examples of usage can be found in the test code in the project.\n\n## Use other Unmarshal package\n\n```go\n\nimport jsoniter \"github.com/json-iterator/go\"\n\ntype tmpStruct struct {\n    RequestID string `gojmapr:\"$.request_id\"`\n}\n\nSetUnmarshalFunc(jsoniter.Unmarshal) // You can use other Unmarshal module ex: json-iterator\n\nvar s tmpStruct\nerr := Unmarshal([]byte(jsonString), \u0026s)\nex.Assert().Nil(err)\nex.Assert().Equal(ex.anserStruct.RequestID, s.RequestID)\n```\n\ngojmapr can use other Unmarshal package ex: json-iterator.  \n\n## Testing\n\ngojmapr uses the testify package for testing.  \nTo run the tests, use the following command:\n\n```bash\ngo test -v ./...\n```\n\n## Dependency\n\n* [github.com/limiu82214/gojpath](http://github.com/limiu82214/gojpath)\n\n## Other\n\nIf you encounter any issues during use, please feel free to raise an issue on the GitHub project or contact me via email.  \nIf you find this project helpful, please consider giving it a star.\n\n## LICENSE\n\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimiu82214%2Fgojmapr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flimiu82214%2Fgojmapr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flimiu82214%2Fgojmapr/lists"}