{"id":18644749,"url":"https://github.com/hjson/hjson-java","last_synced_at":"2025-04-06T07:15:04.647Z","repository":{"id":30397765,"uuid":"33950516","full_name":"hjson/hjson-java","owner":"hjson","description":"Hjson for Java","archived":false,"fork":false,"pushed_at":"2023-10-14T16:17:38.000Z","size":231,"stargazers_count":163,"open_issues_count":6,"forks_count":24,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-30T06:07:39.368Z","etag":null,"topics":["hjson","java"],"latest_commit_sha":null,"homepage":"https://hjson.github.io/","language":"Java","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/hjson.png","metadata":{"files":{"readme":"README.md","changelog":"history.md","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}},"created_at":"2015-04-14T18:50:29.000Z","updated_at":"2025-03-21T06:26:19.000Z","dependencies_parsed_at":"2022-09-03T05:10:26.857Z","dependency_job_id":null,"html_url":"https://github.com/hjson/hjson-java","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hjson","download_url":"https://codeload.github.com/hjson/hjson-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445681,"owners_count":20939961,"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":["hjson","java"],"created_at":"2024-11-07T06:13:29.796Z","updated_at":"2025-04-06T07:15:04.509Z","avatar_url":"https://github.com/hjson.png","language":"Java","readme":"# hjson-java\n\n[![Build Status](https://github.com/hjson/hjson-java/workflows/test/badge.svg)](https://github.com/hjson/hjson-java/actions)\n[![Maven Central](https://img.shields.io/maven-central/v/org.hjson/hjson.svg?style=flat-square)](http://search.maven.org/#search|ga|1|g%3A%22org.hjson%22%20a%3A%22hjson%22)\n[![Javadoc](https://img.shields.io/badge/Javadoc-blue)](http://www.javadoc.io/doc/org.hjson/hjson)\n\n[Hjson](https://hjson.github.io), the Human JSON. A configuration file format for humans. Relaxed syntax, fewer mistakes, more comments.\n\n![Hjson Intro](https://hjson.github.io/hjson1.gif)\n\n```\n{\n  # specify rate in requests/second (because comments are helpful!)\n  rate: 1000\n\n  // prefer c-style comments?\n  /* feeling old fashioned? */\n\n  # did you notice that rate doesn't need quotes?\n  hey: look ma, no quotes for strings either!\n\n  # best of all\n  notice: []\n  anything: ?\n\n  # yes, commas are optional!\n}\n```\n\nThe Java implementation of Hjson is based on [minimal-json](https://github.com/ralfstx/minimal-json). For other platforms see [hjson.github.io](https://hjson.github.io).\n\n# CLI\n\nYou can install the Hjson command line tool by downloading and unpacking the latest [*hjson.zip*](https://github.com/hjson/hjson-java/releases).\n\n- run `hjson -h` for help\n- `hjson file.json` will convert to Hjson.\n- `hjson -j file.hjson` will convert to JSON.\n\n# Install from Maven Central\n\n## Gradle\n\nAdd a dependency to your `build.gradle`:\n\n```\ndependencies {\n  compile 'org.hjson:hjson:3.1.0'\n}\n```\n\n## Maven\n\nAdd a dependency to your `pom.xml`:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.hjson\u003c/groupId\u003e\n  \u003cartifactId\u003ehjson\u003c/artifactId\u003e\n  \u003cversion\u003e3.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Ivy\n\nAdd a dependency to your `ivy.xml`:\n\n```xml\n\u003cdependencies\u003e\n  \u003cdependency org=\"org.hjson\" name=\"hjson\" rev=\"3.1.0\"/\u003e\n\u003c/dependencies\u003e\n```\n\n# Usage\n\nYou can either\n\n- use this libary directly\n- or just convert Hjson to JSON and use it with your *favorite JSON library*.\n\n### Convert\n\n```java\n// convert Hjson to JSON\nString jsonString = JsonValue.readHjson(readerOrHjsonString).toString();\n\n// convert JSON to Hjson\nString hjsonString = JsonValue.readHjson(readerOrJSONString).toString(Stringify.HJSON);\n```\n\n### Read\n\n```java\nJsonObject jsonObject = JsonValue.readHjson(string).asObject();\nJsonArray jsonArray = JsonValue.readHjson(reader).asArray();\n```\n\n`JsonValue.readHjson()` will accept both Hjson and JSON. You can use `JsonValue.readJSON()` to accept JSON input only.\n\n### Object sample\n\n```java\nString name = jsonObject.get(\"name\").asString();\nint age = jsonObject.get(\"age\").asInt(); // asLong(), asFloat(), asDouble(), ...\n\n// or iterate over the members\nfor (Member member : jsonObject) {\n  String name = member.getName();\n  JsonValue value = member.getValue();\n  // ...\n}\n```\n\n### Array sample\n\n```java\nString name = jsonArray.get(0).asString();\nint age = jsonArray.get(1).asInt(); // asLong(), asFloat(), asDouble(), ...\n\n// or iterate over the values\nfor(JsonValue value : jsonArray) {\n  // ...\n}\n```\n\n### Nested sample\n\n```java\n// Example: { \"friends\": [ { \"name\": \"John\", \"age\": 23 }, ... ], ... }\nJsonArray friends = jsonObject.get(\"friends\").asArray();\nString name = friends.get(0).asObject().get(\"name\").asString();\nint age = friends.get(0).asObject().get(\"age\").asInt();\n```\n\n### Create\n\n```java\nJsonObject jsonObject = new JsonObject().add(\"name\", \"John\").add(\"age\", 23);\n// -\u003e { \"name\": \"John\", \"age\", 23 }\n\nJsonArray jsonArray = new JsonArray().add(\"John\").add(23);\n// -\u003e [ \"John\", 23 ]\n```\n\n### Modify\n\n```java\njsonObject.set(\"age\", 24);\njsonArray.set(1, 24); // access element by index\n\njsonObject.remove(\"age\");\njsonArray.remove(1);\n```\n\n### Write\n\nWriting is not buffered (to avoid buffering twice), so you *should* use a BufferedWriter.\n\n```java\njsonObject.writeTo(writer);\njsonObject.writeTo(writer, Stringify.HJSON);\n```\n\n### toString()\n\n```java\njsonObject.toString(Stringify.HJSON); // Hjson output\njsonObject.toString(Stringify.FORMATTED); // formatted JSON output\njsonObject.toString(Stringify.PLAIN); // plain JSON output, default\njsonObject.toString(); // plain\n```\n\n# API\n\n[Documentation](https://hjson.github.io/hjson-java/)\n\n# History\n\n[see history.md](history.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjson%2Fhjson-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhjson%2Fhjson-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjson%2Fhjson-java/lists"}