{"id":37020924,"url":"https://github.com/myibu/json4j","last_synced_at":"2026-01-14T02:27:15.327Z","repository":{"id":57721696,"uuid":"354815378","full_name":"myibu/json4j","owner":"myibu","description":"a package is for JSON conversion in Java enviroment.","archived":false,"fork":false,"pushed_at":"2021-04-17T19:11:59.000Z","size":73,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-06-30T20:38:47.277Z","etag":null,"topics":["java","json"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/myibu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-05T11:43:03.000Z","updated_at":"2021-04-17T19:42:35.000Z","dependencies_parsed_at":"2022-09-26T21:51:45.065Z","dependency_job_id":null,"html_url":"https://github.com/myibu/json4j","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/myibu/json4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myibu%2Fjson4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myibu%2Fjson4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myibu%2Fjson4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myibu%2Fjson4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myibu","download_url":"https://codeload.github.com/myibu/json4j/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myibu%2Fjson4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"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":["java","json"],"created_at":"2026-01-14T02:27:14.667Z","updated_at":"2026-01-14T02:27:15.320Z","avatar_url":"https://github.com/myibu.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# json4j\n\nThe package is for [JSON](https://www.json.org/json-en.html) conversion in Java enviroment.\n\u003ctable\u003e\n\u003cthead\u003e\n\u003ctr\u003e\u003cth\u003eJSON Type\u003c/th\u003e\u003cth\u003eJSON Type Example\u003c/th\u003e\u003cth\u003eJava Type\u003c/th\u003e\u003c/tr\u003e\n\u003c/thead\u003e\u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003eobject\u003c/td\u003e\u003ctd\u003e{}\u003c/td\u003e\u003ctd\u003eJSONObject\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003earray\u003c/td\u003e\u003ctd\u003e[]\u003c/td\u003e\u003ctd\u003eJSONArray\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003estring\u003c/td\u003e\u003ctd\u003e\u0026quot;example\u0026quot;\u003c/td\u003e\u003ctd\u003eString\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003enumber\u003c/td\u003e\u003ctd\u003e1/1.0\u003c/td\u003e\u003ctd\u003eBigInteger/BigDecimal\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\"true\"\u003c/td\u003e\u003ctd\u003etrue\u003c/td\u003e\u003ctd\u003eboolean\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\"false\"\u003c/td\u003e\u003ctd\u003efalse\u003c/td\u003e\u003ctd\u003eboolean\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\"null\"\u003c/td\u003e\u003ctd\u003enull\u003c/td\u003e\u003ctd\u003enull\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n## Implements\n\n\u003e Convert a JSON string into a JSON object\n\n`JSON.parse(value)` is based on stack structure.\nThere are three stacks in the program, `stack` stack for characters,` class_stack` stack for list and dict, `keyvalue_stack` stack for name/value pair.\nScan each character in the string, do the following:\n1.  If is `[`, put type/value into `class_stack` stack\n2.  If is `{`, put type/value into the `class_stack` stack, and put an empty key/value pair (named` border`) into the `keyvalue_stack` stack\n3. If is`,`, according to `class_stack` stack top type (list and dict),` list` is to operate on the top of the `class_stack` stack and call its append method, `dict` is pushed into the `keyvalue_stack` stack\n4. If is `]`, popping all the elements on the top of the `stack` stack until it encounters `[`\n5. If is `}`, pop the `keyvalue_stack` stack and pop all the elements on the top of the stack until it encounters  `border` \n6. If is `:`, operate on the top of the `keyvalue_stack` stack and modify the value in the key/value pair\n7. Other, put characters into the `stack` stack\n\u003e Convert JSON values to JSON strings\n\n`JSON.stringify(value)` is using recursive method.\n1. If it is a basic type in Python (number, string, bool, None), return the corresponding string (1/1.0, \"example\", true/false, null)\n2. If it is list and dict, repeat step 1 for each element in the list and dict\n3. Others, It is a class, consider as a dict type, terating over member variables of a class, do the same action as step 1\n\n## Installation\n```bash\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.github.myibu\u003c/groupId\u003e\n  \u003cartifactId\u003ejson4j\u003c/artifactId\u003e\n  \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Examples\n\n - Convert a JSON string into a JSON object.\n\n```java\nJSONObject jsonObject = JSONObject.parse(\"[\\\"foo\\\", {\\\"bar\\\": [\\\"baz\\\", null, 1.0, 2, true]}]\");\n// or write as following if you donot known the type of th json String\nObject jo = JSON.parse(\"[\\\"foo\\\", {\\\"bar\\\": [\\\"baz\\\", null, 1.0, 2, true]}]\");\n```\n\n - Convert JSON values to JSON strings.\n\n```java\nMap\u003cString,String\u003e map = new HashMap\u003c\u003e();\nmap.put(\"1\", \"00\");\nString jsonString = JSON.toJSONString(map);\n```\n\n- Format JSON object or JSON strings\n\n```java\nMap\u003cString,String\u003e map = new HashMap\u003c\u003e();\nmap.put(\"1\", \"00\");\nString formatedJsonString = JSON.format(map);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyibu%2Fjson4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyibu%2Fjson4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyibu%2Fjson4j/lists"}