Skip to content

Commit 74179be

Browse files
committed
0.8 (yes in one commit)
1 parent 45b849d commit 74179be

96 files changed

Lines changed: 2151 additions & 789 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ the [JSON standard specification][json-spec] and the extended [JSON 5 specificat
77

88
This library is shaped around easy analyzation and manipulation of JSON data.
99

10-
- Easy to use JSON tree representation with little as possible `instanceof` checks and casts
11-
- Quick and easy parsing of files and JSON strings
12-
- Quick serialization with a high variety of formatting options
13-
- Reading and writing of streams containing multiple JSON documents (such as over socket streams)
10+
- Easy to use JSON tree representation with little as possible `instanceof` checks and casts.
11+
- Quick and easy parsing of files and JSON strings.
12+
- Quick serialization with a high variety of formatting options.
13+
- Reading and writing of streams containing multiple JSON documents (such as over socket streams).
14+
- Intuitive conversion of Java objects from and to JSON trees via codecs, with no use of reflection or annotations (currently experimental).
1415
- Support for the [JSON 5 specification][json5-spec].
1516

1617
## Work in progress
@@ -19,21 +20,21 @@ This library is in development and the API can change at any time, although at t
1920

2021
## Installing
2122

22-
The current version is `0.7.2`. This version is compatible with Java 11 and above. However, I plan to drop Java 11 compat and move to Java 17 (allowing for sealing the `JsonNode` interface).
23+
The current version is `0.8`. This version is compatible with Java 17 and above. However, I plan to drop Java 11 compat and move to Java 17 (allowing for sealing the `JsonNode` interface).
2324

24-
The artifact can be installed from my [Maven repository](https://maven.runefox.dev/).
25+
The artifact can be installed from my [Maven repository](https://mvn.runefox.dev/).
2526

2627
### Gradle
2728

28-
```groovy
29+
```kotlin
2930
repositories {
3031
// Add my repository
31-
maven { url "https://maven.runefox.dev/" }
32+
maven { url = uri("https://mvn.runefox.dev/releases") }
3233
}
3334

3435
dependencies {
3536
// Add the artifact
36-
implementation "dev.runefox:json:0.7.2"
37+
implementation("dev.runefox:json:0.8")
3738
}
3839
```
3940

@@ -44,7 +45,7 @@ dependencies {
4445
<!-- Add my repository -->
4546
<repository>
4647
<id>Runefox Maven</id>
47-
<url>https://maven.runefox.dev/</url>
48+
<url>https://mvn.runefox.dev/releases</url>
4849
</repository>
4950
</repositories>
5051

@@ -53,7 +54,7 @@ dependencies {
5354
<dependency>
5455
<groupId>dev.runefox</groupId>
5556
<artifactId>json</artifactId>
56-
<version>0.7.2</version>
57+
<version>0.8</version>
5758
</dependency>
5859
</dependencies>
5960
```
@@ -62,9 +63,9 @@ dependencies {
6263

6364
You can also manually download the artifacts manually from my Maven repository:
6465

65-
- **[Download v0.7.2](https://maven.shadew.net/dev/runefox/json/0.7.2/json-0.7.2.jar)**
66-
- **[Download sources v0.7.2](https://maven.shadew.net/dev/runefox/json/0.7.2/json-0.7.2-sources.jar)**
67-
- **[All artifacts for v0.7.2](https://maven.shadew.net/dev/runefox/json/0.7.2/)**
66+
- **[Download v0.8](https://mvn.runefox.dev/releases/dev/runefox/json/0.8/json-0.8.jar)**
67+
- **[Download sources v0.8](https://mvn.runefox.dev/releases/dev/runefox/json/0.8/json-0.8-sources.jar)**
68+
- **[All artifacts for v0.8](https://mvn.runefox.dev/#/releases/dev/runefox/json/0.8)**
6869

6970
## Usage
7071

@@ -254,7 +255,7 @@ you don't need to worry about it.
254255

255256
### Codecs
256257

257-
Codecs are a handy tool to easily encode and decode Java objects into JSON trees and vice versa. All the logic for this can be found in a separate package: `dev.runefox.json.codec`.
258+
Codecs are a handy tool to easily encode and decode Java objects into JSON trees and vice versa. All the logic for this can be found in a separate package: `dev.runefox.json.codec`. The codec API is still very experimental and may change drastically in further updates.
258259

259260
The main type that is important in defining codecs is the `JsonCodec` interface. This interface contains many base codec definitions, for primitives and other basic Java types. You can use codecs of other types to define new codecs.
260261

@@ -289,7 +290,7 @@ public static final JsonCodec<Person> CODEC
289290
.with("first_name", JsonCodec.STRING, Person::firstName)
290291
.with("last_name", JsonCodec.STRING, Person::lastName)
291292
.with("age", JsonCodec.INT, Person::age)
292-
.build(Person::new)
293+
.build(Person::new);
293294
```
294295

295296
This system is useful for classes with up to 16 serialized fields. Note that a this codec always produces and requires a JSON object. It cannot handle arrays or primitives. See the static methods of `JsonCodec` for other ways to construct codecs.
@@ -335,13 +336,14 @@ requires dev.runefox.json;
335336
```
336337

337338
### Kotlin
339+
Kotlin support is added through a separate artifact. It's named `jsonkt` and follows the same version as the main artifact.
340+
```kotlin
341+
implementation("dev.runefox:jsonkt:<version>")
342+
```
338343

339-
Since 0.7.2 the Kotlin part is a separate artifact and must be added. It's named `jsonkt` and follows
340-
the same version as the main artifact.
341-
342-
Since 0.6.1, the library now integrates better with Kotlin:
344+
The Kotlin support library adds several Kotlin-style wrappers for the JSON API provided by the main artifact.
343345
```kotlin
344-
val json = jsonObject {
346+
val json = JsonObject {
345347
it["x"] = 3
346348
it["y"] = 5
347349
}
@@ -352,13 +354,14 @@ println(json) // {"x": 3, "y": 5, "z": 9}
352354
```
353355

354356
Some extra `JsonNode` factory methods were added to reduce the need of escaping reserved kotlin words in backticks. For
355-
example, `JsonNode.object()` would be called in kotlin as <code>JsonNode.\`object\`()</code>. This is ugly, and since 0.6.1, the `jsonObject()` function is available as a replacement to this. Additional functions like this are added for other types, to keep consistency.
357+
example, `JsonNode.object()` would be called in kotlin as <code>JsonNode.\`object\`()</code>. This is ugly, and the `JsonObject()` function is available as a replacement to this. Additional functions like this are added for other types, to keep consistency.
356358

357-
When using `JsonCodec`s, any object now has the `encoded` infix function, and `JsonNode` also has the reversed `decoded` infix function, allowing for the following syntax:
359+
When using `JsonCodec`s, any object now has the `encode` infix function, and `JsonNode` also has the reversed `decode` infix function, allowing for the following syntax:
358360
```kotlin
359-
val json = LocalDateTime.now() encoded JsonCodec.LOCAL_DATE_TIME
361+
// Note how JsonCodecs provides codec instances with Kotlin type guarantees.
362+
val json = LocalDateTime.now() encode JsonCodecs.LOCAL_DATE_TIME
360363

361-
println(json decoded JsonCodec.LOCAL_DATE_TIME)
364+
println(json decode JsonCodecs.LOCAL_DATE_TIME)
362365
```
363366

364367
Since `JsonNode` has natural `get` and `set` methods, Kotlin allows you to call these using subscript notation:
@@ -373,21 +376,18 @@ obj["foo"] = "bar" // also automatically converted to JsonNode
373376
As an extra feature, elements can be added to an array node using `+=`:
374377

375378
```kotlin
376-
val arr = jsonArray()
379+
val arr = JsonArray()
377380
arr += 1
378381
arr += 2
379-
arr += jsonObject()
382+
arr += JsonObject()
380383

381384
println(arr) // [1, 2, {}]
382385
```
383386

384387

385388
## Documentation
386389

387-
Documentation is being worked on. The most commonly needed parts of the library are well documented with JavaDoc comments. More documentation coming
388-
in later versions.
389-
390-
I am working on hosting the compiled JavaDoc online.
390+
Documentation is provided as JavaDoc (and KDoc) comments in the source code. The most commonly needed parts of the library are well documented with JavaDoc comments. More documentation coming as I work on the project.
391391

392392
## Changelog
393393

@@ -399,7 +399,7 @@ Since 0.7.2, changelogs have moved to GitHub Releases. See [Release v0.7.2](http
399399

400400
Copyright 2022-2025 O. W. Nankman
401401

402-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
402+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the
403403
License. You may obtain a copy of the License at
404404

405405
http://www.apache.org/licenses/LICENSE-2.0

build.gradle.kts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Copyright 2022-2026 O. W. Nankman
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
10+
* AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11+
* language governing permissions and limitations under the License.
12+
*/
13+
114
import dev.runefox.json.ObjectCodecTask
215

316
plugins {
@@ -6,7 +19,7 @@ plugins {
619
}
720

821
group = "dev.runefox"
9-
version = "0.7.2"
22+
version = "0.8"
1023

1124
repositories {
1225
mavenCentral()
@@ -39,8 +52,8 @@ publishing {
3952
repositories {
4053
if ("rfxMavenUser" in properties && "rfxMavenPass" in properties) {
4154
maven {
42-
name = "SamuRepo"
43-
url = uri("https://maven.runefox.dev/releases")
55+
name = "RunefoxMaven"
56+
url = uri("https://mvn.runefox.dev/releases")
4457
credentials {
4558
username = properties["rfxMavenUser"].toString()
4659
password = properties["rfxMavenPass"].toString()

buildSrc/build.gradle.kts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Copyright 2022-2026 O. W. Nankman
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
10+
* AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11+
* language governing permissions and limitations under the License.
12+
*/
13+
114
plugins {
215
id("java")
316
}

buildSrc/src/main/java/dev/runefox/json/ObjectCodecGenerator.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Copyright 2022-2026 O. W. Nankman
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
10+
* AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11+
* language governing permissions and limitations under the License.
12+
*/
13+
114
package dev.runefox.json;
215

316
import java.io.File;

buildSrc/src/main/java/dev/runefox/json/ObjectCodecTask.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Copyright 2022-2026 O. W. Nankman
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
10+
* AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11+
* language governing permissions and limitations under the License.
12+
*/
13+
114
package dev.runefox.json;
215

316
import org.gradle.api.DefaultTask;

gradle/wrapper/gradle-wrapper.properties

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
#
2+
# Copyright 2022-2026 O. W. Nankman
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
5+
# License. You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
10+
# AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11+
# language governing permissions and limitations under the License.
12+
#
13+
114
distributionBase = GRADLE_USER_HOME
215
distributionPath = wrapper/dists
316
distributionUrl = https\://services.gradle.org/distributions/gradle-7.6-bin.zip

gradlew

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonkt/build.gradle.kts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Copyright 2022-2026 O. W. Nankman
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
5+
* License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
10+
* AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
11+
* language governing permissions and limitations under the License.
12+
*/
13+
114
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
215

316
plugins {
@@ -42,8 +55,8 @@ publishing {
4255
repositories {
4356
if ("rfxMavenUser" in properties && "rfxMavenPass" in properties) {
4457
maven {
45-
name = "SamuRepo"
46-
url = uri("https://maven.runefox.dev/releases")
58+
name = "RunefoxMaven"
59+
url = uri("https://mvn.runefox.dev/releases")
4760
credentials {
4861
username = properties["rfxMavenUser"].toString()
4962
password = properties["rfxMavenPass"].toString()

0 commit comments

Comments
 (0)