Open jkroepke opened 4 years ago
Hi Jan-Otto,
Thanks for using my json-merge library/plugin.
Unfortunately the library and plugin currently only support merging JsonObject (not jsonArray).
I had a look to see whether I can extend it to support arrays as well. The big question however is how do you want to merge arrays? For instance in your example what result would you expect? I extended you example with an extra field.
file1.json:
|[ { "key": 1, "name": "something" } ] |
file2.json:
|[ { "key": 2, "type": "object" } ] |
Merge outcome 1 (extend):
|[ { "key": 1, "name": "something" }, { "key": 2, "type": "object" } ] |
Merge outcome 2 (combine):
|[ { |||"key": 2, | "name": "something", "type": "object" } ] |
Either way is possible. I will see if I can make this configurable.
Please let me know what you think.
Regards,
misl
On 30-05-2020 21:25, Jan-Otto Kröpke wrote:
Merging
file1.json:
|[ { "key": 1 } ] |
file2.json:
|[ { "key": 2 } ] |
results into:
|[ERROR] Error while trying to merge Json java.lang.ClassCastException: org.glassfish.json.JsonArrayBuilderImpl$JsonArrayImpl cannot be cast to javax.json.JsonObject at it.traeck.tools.json.merge.mojo.JsonMergeMojo.readObject (JsonMergeMojo.java:145) at it.traeck.tools.json.merge.mojo.JsonMergeMojo.readObjects (JsonMergeMojo.java:128) at it.traeck.tools.json.merge.mojo.JsonMergeMojo.execute (JsonMergeMojo.java:85) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289) at org.apache.maven.cli.MavenCli.main (MavenCli.java:193) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) |
I want to use this plugin to merge the reflection-config.json for graalvm.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/misl/json-merge/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPSETCPLHWNF46NJ7BNP23RUFMSFANCNFSM4NO2GNXA.
-- Minto van der Sluis, Msc Mobile: +31 6 26 01 45 41 Skype: mintovandersluis
Hi,
I need to extend or concat my arrays.
The merge behaivor can be complex, e.g different types, configurable keys. I dont need this.
Merging
file1.json:
file2.json:
results into:
I want to use this plugin to merge the reflection-config.json for graalvm.