Package org.apache.juneau.marshall.hjson


package org.apache.juneau.marshall.hjson
Hjson (Human JSON) format serializer and parser for Apache Juneau.

Hjson extends JSON with human-friendly features designed for configuration files and hand-edited data:

  • Quoteless strings — values without quotes when unambiguous (e.g. name: Alice)
  • Multiline strings — triple single-quote ''' blocks with indentation stripping
  • Comments — #, //, and block comments (/* ... */)
  • Optional commas — newlines can separate object members and array elements
  • Trailing commas — ignored
  • Unquoted keys — object keys need not be quoted when safe
  • Root-braceless objects — top-level content without wrapping {} (parse only)
Syntax summary

Strings: quoteless (to end of line), double-quoted, single-quoted, or multiline '''...'''. Numbers, booleans (true/false), and null follow JSON rules. Objects use {} with key: value pairs; arrays use [].

Java mapping

Objects → JsonMap; arrays → JsonList; strings → String; numbers → Number subclasses; booleans → Boolean; null → null. Beans are created when _type is present or when parsing to a specific bean class.

Usage:

String hjson = HjsonSerializer.DEFAULT.write(myBean); MyBean bean = HjsonParser.DEFAULT.read(hjson, MyBean.class); // Or use the marshaller: String hjson = Hjson.of(myBean); MyBean bean = Hjson.to(hjson, MyBean.class);

See Also: