{"id":31067327,"url":"https://github.com/bububa/ljson","last_synced_at":"2025-09-15T19:58:53.613Z","repository":{"id":277798769,"uuid":"933089975","full_name":"bububa/ljson","owner":"bububa","description":"parse loose json string","archived":false,"fork":false,"pushed_at":"2025-03-10T07:17:44.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T08:25:34.144Z","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/bububa.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-15T05:44:47.000Z","updated_at":"2025-03-10T07:17:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"0888662a-6901-4318-b1e2-488455dd7946","html_url":"https://github.com/bububa/ljson","commit_stats":null,"previous_names":["bububa/ljson"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/bububa/ljson","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fljson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fljson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fljson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fljson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bububa","download_url":"https://codeload.github.com/bububa/ljson/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bububa%2Fljson/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275312966,"owners_count":25442563,"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","status":"online","status_checked_at":"2025-09-15T02:00:09.272Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2025-09-15T19:58:50.623Z","updated_at":"2025-09-15T19:58:53.604Z","avatar_url":"https://github.com/bububa.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LJSON\n\nljson Go is a library that parse loose json string\n\n---\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/bububa/ljson.svg)](https://pkg.go.dev/github.com/bububa/ljson)\n[![Go](https://github.com/bububa/ljson/actions/workflows/go.yml/badge.svg)](https://github.com/bububa/ljson/actions/workflows/go.yml)\n[![goreleaser](https://github.com/bububa/ljson/actions/workflows/goreleaser.yml/badge.svg)](https://github.com/bububa/ljson/actions/workflows/goreleaser.yml)\n[![GitHub go.mod Go version of a Go module](https://img.shields.io/github/go-mod/go-version/bububa/ljson.svg)](https://github.com/bububa/ljson)\n[![GoReportCard](https://goreportcard.com/badge/github.com/bububa/ljson)](https://goreportcard.com/report/github.com/bububa/ljson)\n[![GitHub license](https://img.shields.io/github/license/bububa/ljson.svg)](https://github.com/bububa/ljson/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/bububa/ljson.svg)](https://GitHub.com/bububa/ljson/releases/)\n\n## Install\n\nInstall the package into your code with:\n\n```bash\ngo get \"github.com/bububa/ljson\"\n```\n\nImport in your code:\n\n```go\nimport (\n\t\"github.com/bububa/ljson\"\n)\n```\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/bububa/ljson\"\n)\n\nfunc main() {\n\t// Define the expected schema as a struct\n\ttype Nested struct {\n\t\tA int `json:\"a\"`\n\t}\n\n\ttype MySchema struct {\n\t\tField1    []map[string]string `json:\"field1\"`\n\t\tNestedObj Nested              `json:\"nested\"`\n\t\tNumbers   int                 `json:\"numbers\"`\n\t\tBoolVal   bool                `json:\"bool_val\"`\n\t}\n\n\t// JSON with objects stored as strings and type mismatches\n\tjsonStr := `{\n\t\t\"field1\": \"[{\\\"sub1\\\": \\\"xxx\\\"}, {\\\"sub2\\\": \\\"yyy\\\"}]\",\n    \"nested\": \"{\\\"a\\\": \\\"123\\\"}\",\n\t\t\"numbers\": \"456\",\n\t\t\"bool_val\": \"true\"\n\t}`\n\tarrStr := `[{\n\t\t\"field1\": \"[{\\\"sub1\\\": \\\"xxx\\\"}, {\\\"sub2\\\": \\\"yyy\\\"}]\",\n    \"nested\": \"{\\\"a\\\": \\\"123\\\"}\",\n\t\t\"numbers\": \"456\",\n\t\t\"bool_val\": \"true\"\n  }, {\n\t\t\"field1\": \"[{\\\"sub1\\\": \\\"xxx\\\"}, {\\\"sub2\\\": \\\"yyy\\\"}]\",\n    \"nested\": \"{\\\"a\\\": \\\"123\\\"}\",\n\t\t\"numbers\": \"456\",\n\t\t\"bool_val\": \"true\"\n  }]`\n\tmapStr := `\"{\\\"sub1\\\": \\\"xxx\\\", \\\"sub2\\\": 123}\"`\n\n\t// Define a struct instance to receive the parsed data\n\tvar result MySchema\n\n\t// Unmarshal using our loose parser\n\tif err := ljson.Unmarshal([]byte(jsonStr), \u0026result); err != nil {\n\t\treturn\n\t}\n\n\t// Print the processed result\n\tresultJSON, _ := json.MarshalIndent(result, \"\", \"  \")\n\tfmt.Println(string(resultJSON))\n\n\t// Define a struct instance to receive the parsed data\n\tvar arrResult []MySchema\n\n\t// Unmarshal using our loose parser\n\tif err := l.Unmarshal([]byte(arrStr), \u0026arrResult); err != nil {\n\t\treturn\n\t}\n\n\t// Print the processed result\n\tresultJSON, _ = json.MarshalIndent(arrResult, \"\", \"  \")\n\tfmt.Println(string(resultJSON))\n\n\t// Define a struct instance to receive the parsed data\n\tmapResult := make(map[string]string)\n\n\t// Unmarshal using our loose parser\n\tif err := l.Unmarshal([]byte(mapStr), \u0026mapResult); err != nil {\n\t\treturn\n\t}\n\n\t// Print the processed result\n\tresultJSON, _ = json.MarshalIndent(mapResult, \"\", \"  \")\n\tfmt.Println(string(resultJSON))\n\n\t// Example with interface type\n\tinterfaceData := `{\n\t\t\"some_field\": \"{\\\"a\\\": \\\"456\\\"}\"\n\t}`\n\tvar myInterface interface{}\n\tif err := Unmarshal([]byte(interfaceData), \u0026myInterface); err != nil {\n\t\tfmt.Println(\"Error unmarshalling interface:\", err)\n\t} else {\n\t\tfmt.Printf(\"Unmarshalled interface: %+v\\n\", myInterface)\n\t}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Fljson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbububa%2Fljson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbububa%2Fljson/lists"}