Class IniSerializer

All Implemented Interfaces:
Function<Object,String>, ThrowingFunction<Object,String>, IniMetaProvider, RecordWritable

Serializes POJO models to INI format.

Converts Java POJOs to INI format (section/key-value structure).

Media types

Produces: text/ini
Accepts: text/ini, text/x-ini

Bean-to-INI mapping
  • Simple properties → key-value pairs in the default section
  • Nested beans → [sectionName] sections
  • Deeply nested beans → [path/to/section] section paths
  • Collections and complex values → JSON5-encoded inline values
  • Maps with string keys → [sectionName] sections
  • Null values → unquoted null token
Example:

// Serialize a bean to INI String ini = IniSerializer.DEFAULT.write(myBean); // Create a custom serializer IniSerializer s = IniSerializer.create().useComments().build(); ini = s.write(myBean);

Example output (Map of name/age):

name = Alice age = 30

Complex (nested object + array):

name = Alice age = 30 tags = ['a','b','c'] [address] street = 123 Main St city = Boston state = MA

Limitations

  • Top-level collections, arrays, and scalar values are not supported. The root must be a bean or Map<String,?>. Throws SerializeException for unsupported root types.
  • Reader and InputStream passthrough is not supported.
Notes:
  • This class is thread safe and reusable.
  • Complex values (collections, maps with complex values) are embedded as JSON5 inline strings and remain fully round-trippable.
See Also: