diff --git a/jme3-plugins-json-gson/build.gradle b/jme3-plugins-json-gson/build.gradle new file mode 100644 index 0000000000..6d22f7a774 --- /dev/null +++ b/jme3-plugins-json-gson/build.gradle @@ -0,0 +1,16 @@ +sourceSets { + main { + java { + + srcDir 'src/main/java' + + } + } +} + +dependencies { + + api project(':jme3-plugins-json') + api 'com.google.code.gson:gson:2.9.1' + +} diff --git a/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonArray.java b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonArray.java new file mode 100644 index 0000000000..d3a839a5dc --- /dev/null +++ b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonArray.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.gson; + +import java.util.Iterator; + +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonElement; + +/** + * GSON implementation of {@link JsonArray}. + */ +class GsonArray extends GsonElement implements JsonArray { + + GsonArray(com.google.gson.JsonElement element) { + super(element); + } + + private com.google.gson.JsonArray arr() { + return element.getAsJsonArray(); + } + + @Override + public Iterator iterator() { + return new Iterator() { + Iterator it = arr().iterator(); + + @Override + public boolean hasNext() { + return it.hasNext(); + } + + @Override + public JsonElement next() { + return new GsonElement(it.next()); + } + }; + } + + @Override + public JsonElement get(int i) { + com.google.gson.JsonElement el = arr().get(i); + return isNull(el) ? null : new GsonElement(el); + } + + @Override + public int size() { + return arr().size(); + } + +} diff --git a/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonElement.java b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonElement.java new file mode 100644 index 0000000000..062f60e8ad --- /dev/null +++ b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonElement.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.gson; + +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonElement; +import com.jme3.plugins.json.JsonObject; +import com.jme3.plugins.json.JsonPrimitive; + +/** + * GSON implementation of {@link JsonElement} + */ +class GsonElement implements JsonElement { + com.google.gson.JsonElement element; + + GsonElement(com.google.gson.JsonElement element) { + this.element = element; + } + + protected boolean isNull(com.google.gson.JsonElement element) { + if (element == null) return true; + if (element.isJsonNull()) return true; + return false; + } + + @Override + public String getAsString() { + return element.getAsString(); + } + + @Override + public JsonObject getAsJsonObject() { + return new GsonObject(element.getAsJsonObject()); + } + + @Override + public float getAsFloat() { + return element.getAsFloat(); + } + + @Override + public int getAsInt() { + return element.getAsInt(); + } + + @Override + public Number getAsNumber() { + return element.getAsNumber(); + } + + @Override + public boolean getAsBoolean() { + return element.getAsBoolean(); + } + + @Override + public JsonArray getAsJsonArray() { + return new GsonArray(element.getAsJsonArray()); + } + + @Override + public JsonPrimitive getAsJsonPrimitive() { + return new GsonPrimitive(element.getAsJsonPrimitive()); + } + +} diff --git a/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonObject.java b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonObject.java new file mode 100644 index 0000000000..a69afad20b --- /dev/null +++ b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonObject.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.gson; + +import java.util.Set; +import java.util.Map.Entry; + +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonElement; +import com.jme3.plugins.json.JsonObject; +import com.jme3.plugins.json.JsonPrimitive; + +/** + * GSON implementation of {@link JsonObject} + */ +class GsonObject extends GsonElement implements JsonObject { + + GsonObject(com.google.gson.JsonObject gsonObject) { + super(gsonObject); + } + + private com.google.gson.JsonObject obj() { + return (com.google.gson.JsonObject) element; + } + + @Override + public JsonArray getAsJsonArray(String string) { + com.google.gson.JsonArray el = obj().getAsJsonArray(string); + return isNull(el) ? null : new GsonArray(el); + } + + @Override + public JsonObject getAsJsonObject(String string) { + com.google.gson.JsonObject el = obj().getAsJsonObject(string); + return isNull(el) ? null : new GsonObject(el); + } + + @Override + public boolean has(String string) { + return obj().has(string); + } + + @Override + public JsonElement get(String string) { + com.google.gson.JsonElement el = obj().get(string); + return isNull(el) ? null : new GsonElement(el); + } + + @Override + public Entry[] entrySet() { + Set> entrySet = obj().entrySet(); + Entry[] entries = new Entry[entrySet.size()]; + int i = 0; + for (Entry entry : entrySet) { + + Entry e = new Entry() { + @Override + public String getKey() { + return entry.getKey(); + } + + @Override + public GsonElement getValue() { + return new GsonElement(entry.getValue()); + } + + @Override + public GsonElement setValue(JsonElement value) { + throw new UnsupportedOperationException("Unimplemented method 'setValue'"); + } + }; + + entries[i++] = e; + } + return entries; + + } + + @Override + public JsonPrimitive getAsJsonPrimitive(String string) { + com.google.gson.JsonPrimitive el= obj().getAsJsonPrimitive(string); + return isNull(el) ? null : new GsonPrimitive(el); + } +} \ No newline at end of file diff --git a/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonParser.java b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonParser.java new file mode 100644 index 0000000000..fd7fd0462c --- /dev/null +++ b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonParser.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.gson; + +import java.io.InputStream; +import java.io.InputStreamReader; + +import com.jme3.plugins.json.JsonObject; +import com.jme3.plugins.json.JsonParser; + +/** + * GSON implementation of {@link JsonParser} + */ +public class GsonParser implements JsonParser { + @Override + public JsonObject parse(InputStream stream) { + return new GsonObject(com.google.gson.JsonParser.parseReader(new com.google.gson.stream.JsonReader(new InputStreamReader(stream))).getAsJsonObject()); + } +} diff --git a/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonPrimitive.java b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonPrimitive.java new file mode 100644 index 0000000000..91399bcebb --- /dev/null +++ b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonPrimitive.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.gson; + +import com.jme3.plugins.json.JsonPrimitive; + +/** + * GSON implementation of {@link JsonPrimitive} + */ +public class GsonPrimitive extends GsonElement implements JsonPrimitive { + + public GsonPrimitive(com.google.gson.JsonPrimitive element) { + super(element); + } + + private com.google.gson.JsonPrimitive prim() { + return (com.google.gson.JsonPrimitive) element; + } + + @Override + public boolean isNumber() { + return prim().isNumber(); + } + + @Override + public boolean isBoolean() { + return prim().isBoolean(); + } + + @Override + public boolean isString() { + return prim().isString(); + } + +} diff --git a/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/package-info.java b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/package-info.java new file mode 100644 index 0000000000..df1e88063f --- /dev/null +++ b/jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/package-info.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * A JSON parser that uses Gson internally + */ + +package com.jme3.plugins.gson; diff --git a/jme3-plugins-json/build.gradle b/jme3-plugins-json/build.gradle new file mode 100644 index 0000000000..9a0bb3e43b --- /dev/null +++ b/jme3-plugins-json/build.gradle @@ -0,0 +1,14 @@ +sourceSets { + main { + java { + + srcDir 'src/main/java' + + } + } +} + +dependencies { + + +} diff --git a/jme3-plugins-json/src/main/java/com/jme3/plugins/json/Json.java b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/Json.java new file mode 100644 index 0000000000..19eb8490d6 --- /dev/null +++ b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/Json.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.json; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A json parser factory that allows you to set the parser to use. + * + * @author Riccardo Balbo + */ +public class Json { + /** + * The property name to set the parser to use. + * Should be set automatically by the JmeSystemDelegate. + * Note: changing this property after the first call to Json.create() will have no effect. + */ + public static final String PROPERTY_JSON_PARSER_IMPLEMENTATION = "com.jme3.JsonParserImplementation"; + private static final Logger LOGGER = Logger.getLogger(Json.class.getName()); + private static final String DEFAULT_JSON_PARSER_IMPLEMENTATION = "com.jme3.plugins.gson.GsonParser"; + + private static Class clazz = null; + + /** + * Set the parser to use. + * + * @param clazz + * a class that implements JsonParser + */ + public static void setParser(Class clazz) { + Json.clazz = clazz; + } + + @SuppressWarnings("unchecked") + private static Class findJsonParser(String className) { + Class clazz = null; + + try { + clazz = Class.forName(className); + } catch (final Throwable e) { + LOGGER.log(Level.WARNING, "Unable to access {0}", className); + } + + if (clazz != null && !JsonParser.class.isAssignableFrom(clazz)) { + LOGGER.log(Level.WARNING, "{0} does not implement {1}", new Object[] { className, JsonParser.class.getName() }); + clazz = null; + } + + return (Class) clazz; + } + + /** + * Create a new JsonParser instance. + * + * @return a new JsonParser instance + */ + + public static JsonParser create() { + if (Json.clazz == null) { + String userDefinedImpl = System.getProperty(PROPERTY_JSON_PARSER_IMPLEMENTATION, null); + if (userDefinedImpl != null) { + LOGGER.log(Level.FINE, "Loading user defined JsonParser implementation {0}", userDefinedImpl); + Json.clazz = findJsonParser(userDefinedImpl); + } + if (Json.clazz == null) { + LOGGER.log(Level.FINE, "No usable user defined JsonParser implementation found, using default implementation {0}", DEFAULT_JSON_PARSER_IMPLEMENTATION); + Json.clazz = findJsonParser(DEFAULT_JSON_PARSER_IMPLEMENTATION); + } + } + + if (Json.clazz == null) { + throw new RuntimeException("No JsonParser implementation found"); + } + + try { + return clazz.getDeclaredConstructor().newInstance(); + } catch (Exception e) { + throw new RuntimeException("Could not instantiate JsonParser class " + clazz.getName(), e); + } + } +} diff --git a/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonArray.java b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonArray.java new file mode 100644 index 0000000000..3be3e0321c --- /dev/null +++ b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonArray.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.json; + +/** + * Represents an array. + * + * @author Riccardo Balbo + */ +public interface JsonArray extends Iterable { + /** + * Get the element at index i + * + * @param i + * index + * @return the element + */ + public JsonElement get(int i); + + /** + * Get the size of the array + * + * @return the size + */ + public int size(); +} diff --git a/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonElement.java b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonElement.java new file mode 100644 index 0000000000..ba80e84852 --- /dev/null +++ b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonElement.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.json; + +/** + * A generic element + * + * @author Riccardo Balbo + */ +public interface JsonElement { + + /** + * Returns the object as a String + * + * @return the string + */ + public String getAsString(); + + /** + * Returns the object as a JsonObject + * + * @return the JsonObject + */ + public JsonObject getAsJsonObject(); + + /** + * Returns the object as a float + * + * @return the float + */ + public float getAsFloat(); + + /** + * Returns the object as an int + * + * @return the int + */ + public int getAsInt(); + + /** + * Returns the object as a boolean + * + * @return the boolean + */ + public boolean getAsBoolean(); + + /** + * Returns the object as a JsonArray + * + * @return the JsonArray + */ + public JsonArray getAsJsonArray(); + + + /** + * Returns the object as a Number + * @return the Number + */ + Number getAsNumber(); + + + /** + * Returns the object as a JsonPrimitive + * @return + */ + JsonPrimitive getAsJsonPrimitive(); +} diff --git a/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonObject.java b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonObject.java new file mode 100644 index 0000000000..230cba0da1 --- /dev/null +++ b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonObject.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.json; + +import java.util.Map.Entry; + +/** + * A generic object/map + * + * @author Riccardo Balbo + */ +public interface JsonObject extends JsonElement { + + /** + * Returns the object property as a String + * + * @param string + * name of the property + * @return the string + */ + public JsonArray getAsJsonArray(String string); + + /** + * Returns the object property as a JsonObject + * + * @param string + * name of the property + * @return the JsonObject + */ + public JsonObject getAsJsonObject(String string); + + /** + * Check if the object has a property + * + * @param string + * name of the property + * @return true if it exists, false otherwise + */ + public boolean has(String string); + + /** + * Returns the object property as generic element + * + * @param string + * name of the property + * @return the element + */ + public JsonElement get(String string); + + /** + * Returns the object's key-value pairs + * + * @return an array of key-value pairs + */ + public Entry[] entrySet(); + + /** + * Returns the object property as a wrapped primitive + * + * @param string + * name of the property + * @return the wrapped primitive + */ + public JsonPrimitive getAsJsonPrimitive(String string); + +} diff --git a/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonParser.java b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonParser.java new file mode 100644 index 0000000000..7e87912c87 --- /dev/null +++ b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonParser.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.json; + +import java.io.InputStream; + +/** + * A json parser + * + * @author Riccardo Balbo + */ +public interface JsonParser { + /** + * Parse a json input stream and returns a {@link JsonObject} + * + * @param stream + * the stream to parse + * @return the JsonObject + */ + public JsonObject parse(InputStream stream); +} diff --git a/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonPrimitive.java b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonPrimitive.java new file mode 100644 index 0000000000..ed55a8db77 --- /dev/null +++ b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonPrimitive.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jme3.plugins.json; + +/** + * A wrapped primitive + * + * @author Riccardo Balbo + */ +public interface JsonPrimitive { + /** + * Returns the wrapped primitive as a float + * + * @return the float value + */ + public float getAsFloat(); + + /** + * Returns the wrapped primitive as an int + * + * @return the int value + */ + public int getAsInt(); + + /* + * Returns the wrapped primitive as a boolean + * + * @return the boolean value + */ + public boolean getAsBoolean(); + + /** + * Check if the wrapped primitive is a number + * @return true if it is a number + */ + public boolean isNumber(); + + /** + * Check if the wrapped primitive is a boolean + * @return true if it is a boolean + */ + public boolean isBoolean(); + + /** + * Check if the wrapped primitive is a string + * @return true if it is a string + */ + public boolean isString(); + + /** + * Returns the wrapped primitive as a string + * @return the string value + */ + public String getAsString(); + + /** + * Returns the wrapped primitive as a generic number + * @return the number value + */ + public Number getAsNumber(); +} diff --git a/jme3-plugins-json/src/main/java/com/jme3/plugins/json/package-info.java b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/package-info.java new file mode 100644 index 0000000000..55a9208e1c --- /dev/null +++ b/jme3-plugins-json/src/main/java/com/jme3/plugins/json/package-info.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2009-2023 jMonkeyEngine + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'jMonkeyEngine' nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * An abstraction layer to implement JSON parsers in jMonkeyEngine + */ +package com.jme3.plugins.json; diff --git a/jme3-plugins/build.gradle b/jme3-plugins/build.gradle index b88f0a64fd..1d325314ee 100644 --- a/jme3-plugins/build.gradle +++ b/jme3-plugins/build.gradle @@ -11,6 +11,7 @@ sourceSets { dependencies { api project(':jme3-core') - api 'com.google.code.gson:gson:2.9.1' + implementation project(':jme3-plugins-json') + implementation project(':jme3-plugins-json-gson') testRuntimeOnly project(':jme3-desktop') } diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/CustomContentManager.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/CustomContentManager.java index 5e76201819..6168132313 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/CustomContentManager.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/CustomContentManager.java @@ -31,9 +31,9 @@ */ package com.jme3.scene.plugins.gltf; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.jme3.asset.AssetLoadException; +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonElement; import java.io.IOException; import java.util.HashMap; diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtensionLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtensionLoader.java index 4bdbb29eff..033b200378 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtensionLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtensionLoader.java @@ -31,8 +31,8 @@ */ package com.jme3.scene.plugins.gltf; -import com.google.gson.JsonElement; +import com.jme3.plugins.json.JsonElement; import java.io.IOException; /** diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtrasLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtrasLoader.java index c470478db1..3c4c9819dc 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtrasLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtrasLoader.java @@ -30,8 +30,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jme3.scene.plugins.gltf; - -import com.google.gson.JsonElement; +import com.jme3.plugins.json.JsonElement; /** * Interface to handle a glTF extra. diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java index 2475c01ea9..44fe325aef 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java @@ -31,8 +31,10 @@ */ package com.jme3.scene.plugins.gltf; -import com.google.gson.*; -import com.google.gson.stream.JsonReader; +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonObject; +import com.jme3.plugins.json.JsonPrimitive; +import com.jme3.plugins.json.JsonElement; import com.jme3.anim.*; import com.jme3.asset.*; import com.jme3.material.Material; @@ -119,7 +121,7 @@ protected Object loadFromStream(AssetInfo assetInfo, InputStream stream) throws defaultMat.setFloat("Roughness", 1f); } - docRoot = JsonParser.parseReader(new JsonReader(new InputStreamReader(stream))).getAsJsonObject(); + docRoot = parse(stream); JsonObject asset = docRoot.getAsJsonObject().get("asset").getAsJsonObject(); getAsString(asset, "generator"); diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java index e5b42d99a1..2586a99f15 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java @@ -31,11 +31,15 @@ */ package com.jme3.scene.plugins.gltf; -import com.google.gson.*; import com.jme3.asset.AssetInfo; import com.jme3.asset.AssetLoadException; import com.jme3.math.*; import com.jme3.scene.*; +import com.jme3.plugins.json.Json; +import com.jme3.plugins.json.JsonParser; +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonObject; +import com.jme3.plugins.json.JsonElement; import com.jme3.texture.Texture; import com.jme3.util.*; import java.io.*; @@ -57,6 +61,17 @@ public class GltfUtils { private GltfUtils() { } + + /** + * Parse a json input stream and returns a {@link JsonObject} + * @param stream the stream to parse + * @return the JsonObject + */ + public static JsonObject parse(InputStream stream) { + JsonParser parser = Json.create(); + return parser.parse(stream); + } + public static Mesh.Mode getMeshMode(Integer mode) { if (mode == null) { return Mesh.Mode.Triangles; diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/LightsPunctualExtensionLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/LightsPunctualExtensionLoader.java index 6b98e3f8d7..b3df7dbc88 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/LightsPunctualExtensionLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/LightsPunctualExtensionLoader.java @@ -31,9 +31,9 @@ */ package com.jme3.scene.plugins.gltf; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonObject; +import com.jme3.plugins.json.JsonElement; import com.jme3.asset.AssetLoadException; import com.jme3.light.DirectionalLight; import com.jme3.light.Light; diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/PBRSpecGlossExtensionLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/PBRSpecGlossExtensionLoader.java index 365c49eb29..2ab3862db3 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/PBRSpecGlossExtensionLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/PBRSpecGlossExtensionLoader.java @@ -31,11 +31,10 @@ */ package com.jme3.scene.plugins.gltf; -import com.google.gson.JsonElement; import com.jme3.asset.AssetKey; import java.io.IOException; - +import com.jme3.plugins.json.JsonElement; import static com.jme3.scene.plugins.gltf.GltfUtils.getAsColor; import static com.jme3.scene.plugins.gltf.GltfUtils.getAsFloat; diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/TextureTransformExtensionLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/TextureTransformExtensionLoader.java index d54382d8ac..ea643cea0c 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/TextureTransformExtensionLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/TextureTransformExtensionLoader.java @@ -31,9 +31,9 @@ */ package com.jme3.scene.plugins.gltf; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; +import com.jme3.plugins.json.JsonArray; +import com.jme3.plugins.json.JsonObject; +import com.jme3.plugins.json.JsonElement; import com.jme3.asset.AssetLoadException; import com.jme3.math.Matrix3f; import com.jme3.math.Vector3f; diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/UnlitExtensionLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/UnlitExtensionLoader.java index b9e8d5066a..cb45fcc533 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/UnlitExtensionLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/UnlitExtensionLoader.java @@ -30,8 +30,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jme3.scene.plugins.gltf; - -import com.google.gson.JsonElement; +import com.jme3.plugins.json.JsonElement; import com.jme3.asset.AssetKey; /** diff --git a/settings.gradle b/settings.gradle index 3f6acceb8e..074b2b8a50 100644 --- a/settings.gradle +++ b/settings.gradle @@ -8,6 +8,9 @@ include 'jme3-core' include 'jme3-effects' include 'jme3-networking' include 'jme3-plugins' +include 'jme3-plugins-json' +include 'jme3-plugins-json-gson' + include 'jme3-terrain' // Desktop dependent java classes