Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.example.customer.customtype;


import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonReader;
import io.avaje.jsonb.JsonWriter;
import io.avaje.json.JsonAdapter;
import io.avaje.json.JsonReader;
import io.avaje.json.JsonWriter;
import io.avaje.jsonb.Jsonb;
import io.avaje.jsonb.spi.JsonbComponent;
import io.avaje.spi.ServiceProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.example.other.custom;

import io.avaje.json.JsonAdapter;
import io.avaje.jsonb.CustomAdapter;
import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonReader;
import io.avaje.jsonb.JsonWriter;
import io.avaje.json.JsonReader;
import io.avaje.json.JsonWriter;
import io.avaje.jsonb.Jsonb;
import io.avaje.jsonb.spi.PropertyNames;
import io.avaje.json.PropertyNames;

@CustomAdapter
public class CustomClassJsonAdapter implements JsonAdapter<CustomClass> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
import java.util.AbstractMap.SimpleImmutableEntry;
import java.util.Map.Entry;

import io.avaje.jsonb.CustomAdapter;
import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonReader;
import io.avaje.jsonb.JsonWriter;
import io.avaje.jsonb.Jsonb;
import io.avaje.jsonb.Types;
import io.avaje.jsonb.spi.PropertyNames;
import io.avaje.jsonb.*;
import io.avaje.json.*;

@CustomAdapter
public class CustomEntryJsonAdapter<K, V> implements JsonAdapter<Entry<K, V>> {
Expand All @@ -19,10 +14,9 @@ public class CustomEntryJsonAdapter<K, V> implements JsonAdapter<Entry<K, V>> {
private final JsonAdapter<V> generic2;
private final PropertyNames names;

public static final JsonAdapter.Factory FACTORY =
public static final AdapterFactory FACTORY =
(type, jsonb) -> {
if (Types.isGenericTypeOf(type, Entry.class)) {

return new CustomEntryJsonAdapter<>(jsonb, Types.typeArguments(type));
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import java.math.BigDecimal;
import java.math.RoundingMode;

import io.avaje.json.JsonAdapter;
import io.avaje.jsonb.CustomAdapter;
import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonReader;
import io.avaje.jsonb.JsonWriter;
import io.avaje.json.JsonReader;
import io.avaje.json.JsonWriter;
import io.avaje.jsonb.Jsonb;

@CustomAdapter(global = false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.example.customer;

import io.avaje.json.*;
import io.avaje.jsonb.*;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.example.customer;

import io.avaje.jsonb.JsonException;
import io.avaje.jsonb.JsonType;
import io.avaje.jsonb.Jsonb;
import io.avaje.json.*;
import io.avaje.jsonb.*;
import org.junit.jupiter.api.Test;

import java.io.ByteArrayOutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.example.customer;

import io.avaje.jsonb.JsonWriter;
import io.avaje.json.JsonWriter;
import io.avaje.jsonb.Jsonb;
import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.example.customer.customtype;

import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonReader;
import io.avaje.jsonb.JsonWriter;
import io.avaje.jsonb.Jsonb;
import io.avaje.json.*;
import io.avaje.jsonb.*;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
import org.example.customer.Customer;
import org.junit.jupiter.api.Test;

import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonType;
import io.avaje.jsonb.JsonWriter;
import io.avaje.jsonb.Jsonb;
import io.avaje.jsonb.Types;
import io.avaje.json.*;
import io.avaje.jsonb.*;

class OptionalCustomerTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.avaje.jsonb.JsonType;
import io.avaje.jsonb.Jsonb;
import io.avaje.jsonb.stream.JsonStream;
import io.avaje.json.stream.JsonStream;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;
Expand All @@ -16,7 +16,7 @@ class MyCustomerTest {
@Test
void toJson_fromJson() {

Jsonb jsonb = Jsonb.builder().adapter(new JsonStream()).build();
Jsonb jsonb = Jsonb.builder().adapter(JsonStream.builder().build()).build();

MyCustomer myCustomer = new MyCustomer(42, "rob", "foo");
JsonType<MyCustomer> type = jsonb.type(MyCustomer.class);
Expand All @@ -43,7 +43,7 @@ void toJson_fromJson() {
@Test
void list_toJson_fromJson() {

Jsonb jsonb = Jsonb.builder().adapter(new JsonStream()).build();
Jsonb jsonb = Jsonb.builder().adapter(JsonStream.builder().build()).build();

List<MyCustomer> customers = new ArrayList<>();
customers.add(new MyCustomer(42, "rob", "foo"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import io.avaje.jsonb.JsonType;
import io.avaje.jsonb.Jsonb;
import io.avaje.jsonb.stream.JsonStream;
import io.avaje.json.stream.JsonStream;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class SkipTest {

Jsonb jsonb = Jsonb.builder().adapter(new JsonStream()).build();
Jsonb jsonb = Jsonb.builder().adapter(JsonStream.builder().build()).build();
JsonType<MyCustomer> type = jsonb.type(MyCustomer.class);

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.example.customer.stream;

import io.avaje.jsonb.JsonReader;
import io.avaje.json.*;
import io.avaje.jsonb.JsonType;
import io.avaje.jsonb.Jsonb;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.example.customer.stream;

import io.avaje.jsonb.JsonReader;
import io.avaje.json.*;
import io.avaje.jsonb.JsonType;
import io.avaje.jsonb.Jsonb;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.example.other;

import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonType;
import io.avaje.jsonb.JsonWriter;
import io.avaje.json.*;
import io.avaje.jsonb.Jsonb;
import io.avaje.jsonb.Types;

Expand Down
31 changes: 31 additions & 0 deletions json-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb-parent</artifactId>
<version>2.5-SNAPSHOT</version>
</parent>

<artifactId>avaje-json</artifactId>

<dependencies>
<dependency>
<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver</artifactId>
<version>4.1.0</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.5</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb;
package io.avaje.json;

import java.lang.reflect.Type;

import io.avaje.jsonb.spi.ViewBuilderAware;
import io.avaje.json.view.ViewBuilderAware;

/**
* The core API for serialization to and from json.
Expand Down Expand Up @@ -52,22 +50,9 @@ default boolean isViewBuilderAware() {
}

/**
* Return the ViewBuilder.Aware for this adapter.
* Return the ViewBuilderAware for this adapter.
*/
default ViewBuilderAware viewBuild() {
throw new IllegalStateException("This adapter is not ViewBuilderAware");
}

/**
* Factory for creating a JsonAdapter.
*/
public interface Factory {

/**
* Create and return a JsonAdapter given the type and annotations or return null.
* <p>
* Returning null means that the adapter could be created by another factory.
*/
JsonAdapter<?> create(Type type, Jsonb jsonb);
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb;
package io.avaje.json;

/**
* Thrown when data being parsed is not encoded as valid json or attempting to write invalid json.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.avaje.jsonb;
package io.avaje.json;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb;
package io.avaje.json;

/**
* Thrown when the data being parsed is not encoded as valid JSON,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb;
package io.avaje.json;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb;

import io.avaje.jsonb.spi.PropertyNames;
package io.avaje.json;

import java.io.Closeable;
import java.math.BigDecimal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb;

import io.avaje.jsonb.spi.PropertyNames;
package io.avaje.json;

import java.io.Closeable;
import java.io.Flushable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb;
package io.avaje.json;

import io.avaje.jsonb.spi.ViewBuilderAware;

import io.avaje.json.view.ViewBuilderAware;

final class NullSafeAdapter<T> implements JsonAdapter<T> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package io.avaje.jsonb.spi;

import io.avaje.jsonb.JsonWriter;
package io.avaje.json;

/**
* Marker interface for IOAdapter specific property names.
* <p>
* This can provide support for use of names by index position where
* the names have already been escaped and encoded.
*
* @see JsonWriter#names(PropertyNames)
* @see JsonWriter#allNames(PropertyNames)
* @see JsonWriter#name(int)
*/
public interface PropertyNames {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.avaje.jsonb.core;
package io.avaje.json.core;

import io.avaje.jsonb.JsonAdapter;
import io.avaje.jsonb.JsonReader;
import io.avaje.jsonb.JsonWriter;
import io.avaje.json.JsonAdapter;
import io.avaje.json.JsonReader;
import io.avaje.json.JsonWriter;

import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -29,14 +28,14 @@
* This supports both primitive and object arrays.
*/
final class ArrayAdapter implements JsonAdapter<Object> {
static final Factory FACTORY = (type, jsonb) -> {
Type elementType = Util.arrayComponentType(type);
if (elementType == null) return null;
if (elementType == byte.class) return new ByteArray();
Class<?> elementClass = Util.rawType(elementType);
JsonAdapter<Object> elementAdapter = jsonb.adapter(elementType);

static JsonAdapter<Object> create(Class<?> elementClass, JsonAdapter<Object> elementAdapter) {
return new ArrayAdapter(elementClass, elementAdapter).nullSafe();
};
}

static JsonAdapter<byte[]> byteArray() {
return new ByteArray();
}

private final Class<?> elementClass;
private final JsonAdapter<Object> elementAdapter;
Expand Down Expand Up @@ -75,7 +74,7 @@ public String toString() {
return elementAdapter + ".array()";
}

static final class ByteArray implements JsonAdapter<byte[]> {
private static final class ByteArray implements JsonAdapter<byte[]> {
@Override
public byte[] fromJson(JsonReader reader) {
return reader.readBinary();
Expand Down
Loading
Loading