Code Monkey home page Code Monkey logo

update-jsonkey's Introduction

travis build Commitizen friendly codecov Vesion Downloads

update-jsonkey

In many scenario's we need to update a existing json key value with the new one. I have written a api, where we needs to provide a path of the key to update from the root.

To run the example

  • npm install
  • npm run example

Unit Testing

  • npm run test

Sample Json Provided

  • In this example, i have provided a sample json initally, you can replace the content with your json, or can pass dynamic json.

  • Sample Json

 "testing":{
        "test1":{
            "a":11,
            "b":232
        },
        "test2":{
            "xy":233,
            "zz":"abc xyz",
            "json":{
                "msm":"sds",
                "abc":"weuewo"
                }
            }
    }
}

  • How to use the Api

  • Example 1:

    Suppose if need to update the value of the key "json" in "test2" node i.e testing->test2->json.

    Here root key is "testing" the node in which, we need to find the child key.

    "json" is the end child node, which we need to update.

    The path param value will be "/testing/test2/json".

    The Api call will be :

      function prototype : api.updateJson(path,value,exitingjson)
    
      api.updateJson("/testing/test2/json","newvalue",json)
    
      Value can be anything (String, Number, Json)
    

    In response it will return the full updated json.

  • Example 2:

    Suppose if need to update the value of the root key "testing" itself.

    Here root key is "testing" the node itself is the parent & child.

    The path param value will be "/testing".

      api.updateJson("/testing","newvalue",json)
    

update-jsonkey's People

Contributors

utkarshyeolekar avatar dependabot[bot] avatar

Watchers

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.