{title:'Simplified JSON', updated:'9.0.0'}

The {@link oaj.json.SimpleJsonSerializer} class can be used to serialized POJOs into Simplified JSON notation.

Simplified JSON is identical to JSON except for the following:

- JSON attributes are only quoted when necessary.
- Uses single-quotes for quoting.

##### Examples:

| // Some free-form JSON. | JsonMap map = JsonMap.of( | "foo", "x1", | "_bar", "x2", | " baz ", "x3", | "123", "x4", | "return", "x5", | "", "x6" | );

| // Serialized to standard JSON | { | "foo": "x1", | "_bar": "x2", | " baz ": "x3", | "123": "x4", | "return": "x5", | "": "x6" | }

| // Serialized to simplified JSON | { | foo: 'x1', | _bar: 'x2', | ' baz ': 'x3', // Quoted due to embedded spaces. | '123': 'x4', // Quoted to prevent confusion with number. | 'return': 'x5', // Quoted because it's a keyword. | '': 'x6' // Quoted because it's an empty string. | }

The advantage to simplified JSON is you can represent it in a Java String in minimal form with minimal escaping. This is particularly useful in cases such as unit testing where you can easily validate POJOs by simplifying them to Simplified JSON and do a simple string comparison.

| WriterSerializer serializer = SimpleJsonSerializer.DEFAULT; | assertEquals("{foo:'bar',baz:123}", serializer.toString(myPojo));

- {@link oaj.json.JsonSerializer.Builder}
  - {@link oaj.json.JsonSerializer.Builder#simpleMode() simpleMode()}