You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2019/08/15 09:39:41 UTC
[sling-org-apache-sling-feature-io] branch master updated:
SLING-8632 : Add a method to get a JSON object from an extension
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-io.git
The following commit(s) were added to refs/heads/master by this push:
new 57ef0a1 SLING-8632 : Add a method to get a JSON object from an extension
57ef0a1 is described below
commit 57ef0a1d094f5b9c5727f084a1c1f6a5a40409d1
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Aug 15 11:38:53 2019 +0200
SLING-8632 : Add a method to get a JSON object from an extension
---
.../java/org/apache/sling/feature/io/json/JSONReaderBase.java | 8 +-------
.../java/org/apache/sling/feature/io/json/JSONWriterBase.java | 8 +-------
2 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
index 1d113e3..c1be04e 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
@@ -38,7 +38,6 @@ import javax.json.JsonArrayBuilder;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonStructure;
-import javax.json.JsonWriter;
import org.apache.felix.configurator.impl.json.JSMin;
import org.apache.felix.configurator.impl.json.JSONUtil;
@@ -397,12 +396,7 @@ abstract class JSONReaderBase {
break;
case JSON : checkType("JSON Extension " + name, value, Map.class, List.class);
final JsonStructure struct = build(value);
- try ( final StringWriter w = new StringWriter()) {
- final JsonWriter jw = Json.createWriter(w);
- jw.write(struct);
- w.flush();
- ext.setJSON(w.toString());
- }
+ ext.setJSONStructure(struct);
break;
case TEXT : checkType("Text Extension " + name, value, String.class, List.class);
if ( value instanceof String ) {
diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java b/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
index c41ddff..66b6ed2 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONWriterBase.java
@@ -16,7 +16,6 @@
*/
package org.apache.sling.feature.io.json;
-import java.io.StringReader;
import java.io.Writer;
import java.lang.reflect.Array;
import java.util.Collection;
@@ -26,7 +25,6 @@ import java.util.List;
import java.util.Map;
import javax.json.Json;
-import javax.json.JsonStructure;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonGeneratorFactory;
@@ -225,11 +223,7 @@ abstract class JSONWriterBase {
}
final String key = ext.getName().concat(":").concat(ext.getType().name()).concat("|").concat(state);
if ( ext.getType() == ExtensionType.JSON ) {
- final JsonStructure struct;
- try ( final StringReader reader = new StringReader(ext.getJSON()) ) {
- struct = Json.createReader(reader).read();
- }
- generator.write(key, struct);
+ generator.write(key, ext.getJSONStructure());
} else if ( ext.getType() == ExtensionType.TEXT ) {
generator.writeStartArray(key);
for(String line : ext.getText().split("\n")) {