{"id":18894240,"url":"https://github.com/pixelguys/trivialjson","last_synced_at":"2026-02-27T07:30:17.624Z","repository":{"id":102019389,"uuid":"465073273","full_name":"PixelGuys/TrivialJson","owner":"PixelGuys","description":"A json parser designed to trivially read config files","archived":false,"fork":false,"pushed_at":"2022-04-03T13:43:20.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T07:24:50.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PixelGuys.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":"2022-03-01T22:12:34.000Z","updated_at":"2022-03-01T23:52:59.000Z","dependencies_parsed_at":"2023-05-22T05:30:45.416Z","dependency_job_id":null,"html_url":"https://github.com/PixelGuys/TrivialJson","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixelGuys%2FTrivialJson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixelGuys%2FTrivialJson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixelGuys%2FTrivialJson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PixelGuys%2FTrivialJson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PixelGuys","download_url":"https://codeload.github.com/PixelGuys/TrivialJson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239869218,"owners_count":19710485,"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","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-11-08T08:20:17.568Z","updated_at":"2026-02-27T07:30:17.557Z","avatar_url":"https://github.com/PixelGuys.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TrivialJson\n## Goals\nMost json libraries out there (at least the ones I've seen) are complicated to use.\\\nEspecially for parsing config files, it can be quite tedious having to check for every single value if it exists.\n\nSo I wanted to make an easy to use json library that avoids all those checks, while still being safe from errors.\\\nFor that I'm requiring default values that are returned if the key isn't found.\n\nAdditionally I wanted to have support for hexadecimal numbers (e.g. `0xff008b`).\\\nThis obviously means that the parser uses a super-set of json.\n\nThe parser is also quite forgiving when it comes to smaller errors, such as missing or additional `,`.\n## Example\n#### Creating json\n```java\nJsonObject ore = new JsonObject();\nore.put(\"veins\", 7.5);\nore.put(\"size\", 9);\nore.put(\"height\", 68);\nore.put(\"density\", 0.1f);\nJsonArray oreSources = new JsonArray();\noreSources.addStrings(\"cubyz:stone\", \"cubyz:soil\");\nore.put(\"sources\", oreSources);\nSystem.out.println(json.toString());\n// {\"veins\":7.5,\"size\":9,\"height\":68,\"density\":0.1,\"source\":[\"cubyz:stone\", \"cubyz:soil\"]}\n```\n#### Reading json\n```java\nJsonObject json = JsonParser.parseObjectFromFile(\"path/to/file\");\nbreakingPower = json.getFloat(\"breakingPower\", 0);\nhardness = json.getFloat(\"hardness\", 1);\nblockClass = BlockClass.valueOf(json.getString(\"class\", \"STONE\").toUpperCase());\nlight = json.getInt(\"emittedLight\", 0);\nabsorption = json.getInt(\"absorbedLight\", 0);\nlightingTransparent = json.has(\"absorbedLight\");\n// No matter what's inside of path/to/file, there will be no exception thrown here, but there will be error messages.\n```\n#### Changing the error output\nWhen the parser encounters errors, it will print an error message. But it will keep parsing, trying to get some output rather than none.\n```java\nJson.setErrorHandler((error) -\u003e Logger.warning(error));\n// On default the error gets output to System.out.println().\n```\n## Usage\n#### maven\nAdd this to your `pom.xml` file:\n```xml\n\t\u003crepositories\u003e\n\t\t... (other repositories)\n\t\t\u003crepository\u003e\n\t\t\t\u003cid\u003ecubyz\u003c/id\u003e\n\t\t\t\u003curl\u003ehttps://raw.githubusercontent.com/PixelGuys/Cubyz-Dependencies/master/\u003c/url\u003e\n\t\t\t\u003cname\u003ecubyz\u003c/name\u003e\n\t\t\u003c/repository\u003e\n\t\u003c/repositories\u003e\n\t...\n\t\t\u003cdependency\u003e\n\t\t\t\u003cgroupId\u003epixelguys.json\u003c/groupId\u003e\n\t\t\t\u003cartifactId\u003etrivial-json\u003c/artifactId\u003e\n\t\t\t\u003cversion\u003e1.1\u003c/version\u003e\n\t\t\u003c/dependency\u003e\n```\n#### other\nGet the jar file from the release section.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelguys%2Ftrivialjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixelguys%2Ftrivialjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixelguys%2Ftrivialjson/lists"}