27 lines
701 B
Markdown
27 lines
701 B
Markdown
# json
|
|
|
|
A simple JSON library with support for `StringTemplate`s which were available in JDK 21 and 22 as a preview
|
|
feature and removed again in JDK 23. The library allows placeholders to be used as keys, values and inside strings.
|
|
|
|
### Example
|
|
```java
|
|
var parameter = "numbers";
|
|
var value = List.of(1, 2, 3, 4);
|
|
var name = "World";
|
|
|
|
var json = JSON_OBJECT."""
|
|
{
|
|
\{parameter}: \{value},
|
|
"string": "Hello \{name}!"
|
|
}
|
|
""";
|
|
|
|
assertEquals(3, json.getArray("numbers").getNumber(2));
|
|
assertEquals(JsonString.valueOf("Hello World!"), json.get("string"));
|
|
|
|
System.out.println(json.toPrettyJsonString());
|
|
// {
|
|
// "numbers": [1, 2, 3, 4],
|
|
// "string": "Hello World!"
|
|
// }
|
|
``` |