You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by st...@apache.org on 2019/07/25 15:21:58 UTC
[johnzon] branch master updated (4327ea2 -> a9b6153)
This is an automated email from the ASF dual-hosted git repository.
struberg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git.
from 4327ea2 JOHNZON-218 ensure to not allocate BufferStrategy.BufferProvider in JsonProviderImpl when not needed
new 014ef1e JOHNZON-206: Tests for nested toStructure mapping
new a9b6153 JOHNZON-206 properly handle JsonValues in arrays
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../johnzon/mapper/MappingGeneratorImpl.java | 2 ++
.../java/org/apache/johnzon/mapper/MapperTest.java | 31 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
[johnzon] 02/02: JOHNZON-206 properly handle JsonValues in arrays
Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git
commit a9b615331b1e9830b8ce3b01ea2ec996c7f7c60b
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Jul 25 17:20:49 2019 +0200
JOHNZON-206 properly handle JsonValues in arrays
txs to elexx for the report and unit test!
---
.../src/main/java/org/apache/johnzon/mapper/MappingGeneratorImpl.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingGeneratorImpl.java b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingGeneratorImpl.java
index f022562..1b7721e 100644
--- a/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingGeneratorImpl.java
+++ b/johnzon-mapper/src/main/java/org/apache/johnzon/mapper/MappingGeneratorImpl.java
@@ -569,6 +569,8 @@ public class MappingGeneratorImpl implements MappingGenerator {
if (valJsonPointer != null) {
// write the JsonPointer as String natively
generator.write(valJsonPointer);
+ } else if (o instanceof JsonValue) {
+ generator.write((JsonValue) o);
} else {
writeItem(itemConverter != null ? itemConverter.from(o) : o, ignoredProperties, isDeduplicateObjects ? new JsonPointerTracker(jsonPointer, i) : null);
}
[johnzon] 01/02: JOHNZON-206: Tests for nested toStructure mapping
Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/johnzon.git
commit 014ef1e19b25a327c3c7108bab9358ca36bca98c
Author: Alexander Falb <el...@apache.org>
AuthorDate: Mon Apr 1 18:29:55 2019 +0200
JOHNZON-206: Tests for nested toStructure mapping
Signed-off-by: Mark Struberg <st...@apache.org>
---
.../java/org/apache/johnzon/mapper/MapperTest.java | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/MapperTest.java b/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/MapperTest.java
index 0aa4ccb..45def70 100644
--- a/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/MapperTest.java
+++ b/johnzon-mapper/src/test/java/org/apache/johnzon/mapper/MapperTest.java
@@ -54,6 +54,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonValue;
@@ -127,6 +128,36 @@ public class MapperTest {
}
@Test
+ public void mapToJsonObject() {
+ final JsonObject expectedObject = Json.createObjectBuilder().add("a", 1).build();
+ final JsonValue structure = new MapperBuilder().build().toStructure(expectedObject);
+ assertEquals(JsonValue.ValueType.OBJECT, structure.getValueType());
+ final JsonObject actualObject = structure.asJsonObject();
+ assertEquals("{\"a\":1}", actualObject.toString());
+ }
+
+ @Test
+ public void mapToJsonArrayOfJsonObjects() {
+ final JsonObject expectedObjectA = Json.createObjectBuilder().add("a", 1).build();
+ final JsonObject expectedObjectB = Json.createObjectBuilder().add("b", 2).build();
+ final JsonArray expectedArray = Json.createArrayBuilder().add(expectedObjectA).add(expectedObjectB).build();
+ final JsonValue structure = new MapperBuilder().build().toStructure(expectedArray);
+ assertEquals(JsonValue.ValueType.ARRAY, structure.getValueType());
+ final JsonArray actualArray = structure.asJsonArray();
+ assertEquals("[{\"a\":1},{\"b\":2}]", actualArray.toString());
+ }
+
+ @Test
+ public void mapToArrayOfJsonObjects() {
+ final JsonObject expectedObjectA = Json.createObjectBuilder().add("a", 1).build();
+ final JsonObject expectedObjectB = Json.createObjectBuilder().add("b", 2).build();
+ final JsonValue structure = new MapperBuilder().build().toStructure(new Object[]{expectedObjectA, expectedObjectB});
+ assertEquals(JsonValue.ValueType.ARRAY, structure.getValueType());
+ final JsonArray actualArray = structure.asJsonArray();
+ assertEquals("[{\"a\":1},{\"b\":2}]", actualArray.toString());
+ }
+
+ @Test
public void ignoreAllStrategy() {
final StringWriter writer = new StringWriter();
final Child object = new Child();