Przeglądaj źródła

JSON parser abstraction. (#2060)

Riccardo Balbo 2 lat temu
rodzic
commit
4c87531f03
26 zmienionych plików z 1038 dodań i 20 usunięć
  1. 16 0
      jme3-plugins-json-gson/build.gradle
  2. 80 0
      jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonArray.java
  3. 95 0
      jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonElement.java
  4. 113 0
      jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonObject.java
  5. 48 0
      jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonParser.java
  6. 64 0
      jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonPrimitive.java
  7. 37 0
      jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/package-info.java
  8. 14 0
      jme3-plugins-json/build.gradle
  9. 111 0
      jme3-plugins-json/src/main/java/com/jme3/plugins/json/Json.java
  10. 55 0
      jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonArray.java
  11. 96 0
      jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonElement.java
  12. 95 0
      jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonObject.java
  13. 50 0
      jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonParser.java
  14. 90 0
      jme3-plugins-json/src/main/java/com/jme3/plugins/json/JsonPrimitive.java
  15. 36 0
      jme3-plugins-json/src/main/java/com/jme3/plugins/json/package-info.java
  16. 2 1
      jme3-plugins/build.gradle
  17. 2 2
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/CustomContentManager.java
  18. 1 1
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtensionLoader.java
  19. 1 2
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtrasLoader.java
  20. 5 3
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java
  21. 16 1
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfUtils.java
  22. 3 3
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/LightsPunctualExtensionLoader.java
  23. 1 2
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/PBRSpecGlossExtensionLoader.java
  24. 3 3
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/TextureTransformExtensionLoader.java
  25. 1 2
      jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/UnlitExtensionLoader.java
  26. 3 0
      settings.gradle

+ 16 - 0
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'
+
+}

+ 80 - 0
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<JsonElement> iterator() {
+        return new Iterator<JsonElement>() {
+            Iterator<com.google.gson.JsonElement> 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();
+    }
+
+}

+ 95 - 0
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());
+    }
+    
+}

+ 113 - 0
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<String, JsonElement>[] entrySet() {
+        Set<Entry<String, com.google.gson.JsonElement>> entrySet = obj().entrySet();
+        Entry<String, JsonElement>[] entries = new Entry[entrySet.size()];
+        int i = 0;
+        for (Entry<String, com.google.gson.JsonElement> entry : entrySet) {
+
+            Entry<String, JsonElement> e = new Entry<String, JsonElement>() {
+                @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);
+    }
+}

+ 48 - 0
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());
+    }
+}

+ 64 - 0
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();
+    }
+    
+}

+ 37 - 0
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;

+ 14 - 0
jme3-plugins-json/build.gradle

@@ -0,0 +1,14 @@
+sourceSets {
+    main {
+        java {
+           
+            srcDir 'src/main/java'
+
+        }
+    }
+}
+
+dependencies {
+
+
+}

+ 111 - 0
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<? extends JsonParser> clazz = null;
+
+    /**
+     * Set the parser to use.
+     * 
+     * @param clazz
+     *            a class that implements JsonParser
+     */
+    public static void setParser(Class<? extends JsonParser> clazz) {
+        Json.clazz = clazz;
+    }
+
+    @SuppressWarnings("unchecked")
+    private static Class<? extends JsonParser> 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<? extends JsonParser>) 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);
+        }
+    }
+}

+ 55 - 0
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<JsonElement> {
+    /**
+     * 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();
+}

+ 96 - 0
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();
+}

+ 95 - 0
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<String, JsonElement>[] entrySet();
+
+    /**
+     * Returns the object property as a wrapped primitive
+     * 
+     * @param string
+     *            name of the property
+     * @return the wrapped primitive
+     */
+    public JsonPrimitive getAsJsonPrimitive(String string);
+
+}

+ 50 - 0
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);
+}

+ 90 - 0
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();
+}

+ 36 - 0
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;

+ 2 - 1
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')
 }

+ 2 - 2
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;

+ 1 - 1
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;
 
 /**

+ 1 - 2
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.

+ 5 - 3
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 @@ public class GltfLoader implements AssetLoader {
                 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");

+ 16 - 1
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;

+ 3 - 3
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;

+ 1 - 2
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;
 

+ 3 - 3
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;

+ 1 - 2
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;
 
 /**

+ 3 - 0
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