https://github.com/chrimle/record2json
Parse and convert stringified Java records into JSON.
https://github.com/chrimle/record2json
java java-records json strings
Last synced: about 2 months ago
JSON representation
Parse and convert stringified Java records into JSON.
- Host: GitHub
- URL: https://github.com/chrimle/record2json
- Owner: Chrimle
- License: apache-2.0
- Created: 2025-01-07T21:33:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-07T23:22:42.000Z (over 1 year ago)
- Last Synced: 2026-04-23T05:21:50.854Z (2 months ago)
- Topics: java, java-records, json, strings
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Record2JSON
_Parse and convert stringified Java records into JSON._
## Background
With the introduction of Java records in Java 16, the default `toString()` implementation provides a more human-readable string representation of objects.This improved format, e.g. `ExampleRecord(field1=value1, field2=value2)`, is useful for debugging and logging. However, this string representation should **not** be mistaken for serialization, as it is not intended for data exchange or persistence.
## Purpose
There may be scenarios where a record has been stringified, _e.g. in logs_, and needs to be recovered and serialized into a JSON for further processing. Record2JSON parses the string and converts it into a valid JSON string.
## Features
(Draft Roadmap)
1. Validate Input String
- Ensure that the input string is a valid stringified record.
2. Validate Record Structure
- Support providing a JSON Schema for the expected structure.
- Support providing field names and `Class>` arguments for the expected structure.
3. Further Configurations
- Support additional customizations.
- Prettify, for example
4. Return a Valid JSON String
- Convert the parsed object into a JSON string.