Open terrywbrady opened 3 years ago
Mark and I discovered another issue. JSON clients expect text containing newlines to be serialized as "\n" in place of newline characters. Currently, newlines are being treated as spaces.
This issue recently created some challenges for @mreyescdl , so we should discuss this at the next team meeting.
JSON can be validated against a schema. We make use of this in the Merritt Object Health prototype. A JSON schema can be written in either JSON or YAML. The YAML is easier to read. The YAML may need to be converted to JSON when using the schema.
Here are a couple sample schemas.
For more information, see https://json-schema.org/
Example workaround for this issue. https://github.com/CDLUC3/mrt-ingest/blob/main/ingest-it/src/test/java/org/cdlib/mrt/ingest/ServiceDriverIT.java#L143-L185
The Core2 approach for generating JSON can cause inconsistent return types for specific key values. The library is an XML to JSON conversion without schema awareness. When only one value is returned, it is returned as a value. When 2 or more values are returned, the return object becomes an array.
If Merritt publishes a public-facing API, any JSON that is published should consistently publish objects, arrays or values.
I recommend that we re-visit this when we start our API work. In the past I have used GSON. https://github.com/google/gson