Code Monkey home page Code Monkey logo

jsonmerge's Introduction

Hi there

  • I'm a Product Owner and Software Developer from São Paulo, Brazil.
  • I'm currently working with Java (Back-end) for a telecom solution in the AWS cloud.
  • I like to create tools to help developers increase productivity.
  • Ask me about JSON, OOP, design patterns, unit testing, and cloud-native software design.

GitHub stats

jsonmerge's People

Contributors

dependabot[bot] avatar oswaldobapvicjr avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

woorigel

jsonmerge's Issues

NoClassDefFoundError for optional dependency on JsonProviderFactory

Describe the bug
JsonProviderFactory throws a NoClassDefFoundError for an optional (not required) JsonProvider not in the classpath during class loading.

To Reproduce
Steps to reproduce the behavior:

  1. Import jsonmerge with no optional dependency.
  2. Create a new JsonMerger without specifying a concrete Provider (declare a JSON object type instead):
JsonMerger<JsonObject> merger = new JsonMerger<>(JsonObject.class);

Expected behavior
A new JsonMerger with the JsonSmartJsonProvider attached should be created and delivered.

Screenshots
N/A

Additional context
N/A

Additional options for merging arrays

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Based on the fluent API proposed on #6, add new methods to configure fine options to be applied during the merge of arrays identified by a valid JsonPath:

For example (suggested API improvement):

// Explicitly describe the current behavior applied when no MergeOption is provided
MergeOption.onPath("$.myArray")
           .addDistinctObjectsOnly(); // avoid duplicate objects in the array

// Add new option
MergeOption.onPath("$.myArray")
           .addAll(); // additional option where duplicates must be kept

Describe alternatives you've considered
N/A

Additional context
N/a

Add support to Eclipse Vert.x JsonObject

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Add new JsonProvider implementation to Vert.x's JsonObject.

Describe alternatives you've considered
N/A

Additional context
vert.x is a toolkit for reactive programming created by the developers of Eclipse. It's used by 1K+ open source projects in Maven Central. And it encapsulates a special JsonObject implementation used by that framework.

<!-- https://mvnrepository.com/artifact/io.vertx/vertx-core -->
<dependency>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-core</artifactId>
    <version>4.3.3</version>
</dependency>

This enhancement aims to provide JSON Merge to work seamlessly with the JsonObject handled by the vert.x framework.

The new dependency shall be optional to avoid an unnecessary dependency on applications that do not use vert.x.

Tasks

  • Add vert.x dependency (optional) to the jsonmerge-core project.
  • Create a new JsonProvider implementation named VertxJsonProvider
  • Create JUnit test suite VertxJsonProviderTest
  • Create JUnit test suite JsonMergerVertxJsonProvider extending JsonMergerTest to secure that all tests available for the other providers may pass for the new provider as well
  • Update README.md with new provider information

High-severity DoS vulnerabilty found on 3PP json-smart

Impact

Affected versions of net.minidev:json-smart are vulnerable to Denial of Service (DoS) due to a StackOverflowError when parsing a deeply nested JSON array or object.

When reaching a ‘[‘ or ‘{‘ character in the JSON input, the code parses an array or an object respectively. It was discovered that the 3PP does not have any limit to the nesting of such arrays or objects. Since the parsing of nested arrays and objects is done recursively, nesting too many of them can cause stack exhaustion (stack overflow) and crash the software.

Patches

This vulnerability was fixed in json-smart version 2.4.9, but the maintainer recommends upgrading to 2.4.10, due to a remaining bug.

Workarounds

N/A

References

Support deep merge of distinct objects inside array path

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
Currently, when two objects are identified as the same using the provided distinct keys in an array, the algorithm picks the object from the higher-precedence JSON. However, it could be interesting to have an option to do a deep merge of local objects too, by accepting a new parameter.

For example (suggested API improvement):

// Current option, but with chained calls for better usability
MergeOption.onPath("$.myArray")
           .findObjectsIdentifiedBy("id", "version")
           .thenPickTheHigherPrecedenceOne();

// New option
MergeOption.onPath("$.myArray")
           .findObjectsIdentifiedBy("id", "version")
           .thenDoADeepMerge(); //merge the two with the same distinct keys

Describe alternatives you've considered
N/A

Additional context
N/a

Tasks list

  • Implement builder with fluent API for JsonMergeOption
  • Add new flag for deep merge
  • Apply deep merge logic
  • Secure functionality of legacy logic
  • Add new JUnits
  • Javadoc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.