-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON parser abstraction. #2060
JSON parser abstraction. #2060
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@riccardobl Thanks for the PR Ricc, if you don't mind, I would like to just add some suggested changes here, on top of that, I think we need a package-info.java
for the new packages and an example illustrating the use of this new API.
jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonArray.java
Outdated
Show resolved
Hide resolved
jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonArray.java
Outdated
Show resolved
Hide resolved
jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonElement.java
Outdated
Show resolved
Hide resolved
jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonElement.java
Outdated
Show resolved
Hide resolved
jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonObject.java
Outdated
Show resolved
Hide resolved
jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonObject.java
Show resolved
Hide resolved
jme3-plugins-json-gson/src/main/java/com/jme3/plugins/gson/GsonObject.java
Show resolved
Hide resolved
jme3-plugins-json/src/main/java/com/jme3/plugins/json/Json.java
Outdated
Show resolved
Hide resolved
Have you tried to see if GSON fails with teavm? And do you perhaps have another JSON library in mind that can be used safely with teavm on the web? |
Yes, it fails. Luckily javascript has its own default JSON parser, so for the teavm backend it was just a matter of wrapping it in this abstraction, no external library needed. |
Do you think jme3-plugins-json abstraction should also expose interface for mapping JSON to/from Java objects? |
Thanks for the review. |
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/CustomContentManager.java
Outdated
Show resolved
Hide resolved
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtensionLoader.java
Outdated
Show resolved
Hide resolved
jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/ExtrasLoader.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, looks fine to me, please notice that there are still some wildcard imports and non-documented public fields distributed among some source files.
Thank you.
EDIT: and some code formatting errors too.
I don't think so, because that would be very hard to implement without using reflections or other tricks |
This PR substitutes the obligatory gson dependency in jme3-plugins with an abstraction, akin to the BufferAllocationFactory system. This change allows the developers to bind a custom JSON parser implementation through System properties as replacement for the default parser that uses GSON.
This PR introduces two new modules:
Both modules are included as dependencies within jme3-plugins, to maintain backward compatibility. However, in the future, developers should be encouraged to manually add jme3-plugins-json-gson into their build.gradle files.
The goal of this PR is to improve compatibility with non-standard JVMs and platforms, since GSON is a pretty complex library that heavily relies on reflection and Java internals (such as Unsafe), and for this reason it is very hard to port on different platforms.