Giter Club home page Giter Club logo

json_diff_ex's Introduction

JsonDiffEx

Diff and patch for JSON in Elixir, works really well and is really fast

Installation

First, add JsonDiffEx to your mix.exs dependencies:

def deps do
  [{:json_diff_ex, "~> 0.5.0"}]
end

Then, update your dependencies:

$ mix deps.get

Using

Diff

Simple example:

JsonDiffEx.diff %{"test" => 1}, %{"test" => 2}
#=> %{"test" => [1, 2]}

Now with list:

JsonDiffEx.diff %{"test" => [1,2,3]}, %{"test" => [2,3]}
#=> %{"test" => %{"_0" => [1, 0, 0], "_t" => "a"}}

Now with a map in the map:

JsonDiffEx.diff %{"test" => %{"1": 1}}, %{"test" => %{"1": 2}}
#=> %{"test" => %{"1": [1, 2]}}

Now with a map in an list in the map:

JsonDiffEx.diff %{"test" => [%{"1": 1}]}, %{"test" => [%{"1": 2}]}
#=> %{"test" => %{"0" => %{"1": [1, 2]}, "_t" => "a"}}

Patch

Simple example of a patch:

JsonDiffEx.patch %{"test" => 1}, %{"test" => [1, 2]}
#=> %{"test" => 2}

Now a patch with list:

JsonDiffEx.patch %{"test" => [1,2,3]}, %{"test" => %{"_0" => [1, 0, 0], "_t" => "a"}}
#=> %{"test" => [2,3]}

Now a patch with a map in the map:

JsonDiffEx.patch %{"test" => %{"1": 1}}, %{"test" => %{"1": [1, 2]}}
#=> %{"test" => %{"1": 2}}

Now with a map in an list in the map:

JsonDiffEx.patch %{"test" => [%{"1": 1}]}, %{"test" => %{"0" => %{"1": [1, 2]}, "_t" => "a"}}
#=> %{"test" => [%{"1": 2}]}

Compatibility

Should work with jsondiffpatch and the test cases currently test make sure we keep that compatibility.

Profiling

Get medium profiling tests

$ MIX_ENV=test mix run profile/get_usda_json.exs

Run medium profiling tests

$ MIX_ENV=test mix run profile/medium.exs

Run medium profiling tools

$ MIX_ENV=test mix profile.fprof profile/medium.exs

Get big profiling tests

$ MIX_ENV=test mix run profile/get_mtg_json.exs

Run big profiling tests

$ MIX_ENV=test mix run profile/big.exs

Do not run the big profile with mix profile.fprof unless you have a really good computer and don't mind crashing your computer, haven't been able to finish it my self.

Links

Package

Documentation

json_diff_ex's People

Contributors

olafurara avatar olafura avatar

Watchers

Mark Nijhof avatar James Cloos avatar

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.