Skip to content

A command line interface about merging two JSON-Files with replacement in strict mode.

Notifications You must be signed in to change notification settings

mooooooi/json-mergex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Merge Extend

Attribute

  • Interactive operation! You only answer some question.
  • Offer a binary executor.
  • Support variable replacement.
  • Search the working file intelligently.
  • Check invalid replacement.

Usage

With Node.js

npm install -g json-mergex

With binary executor

  1. Go to release page and download file for your platform.
  2. (For windows) Double-click at the json-mergex-win.exe.
  3. (For macos/linux) Execute the json-mergex-xxx in Terminate.

You can check the version via json-mergex -V or look for help via json-mergex -h.

Example

Prepare the source data

New the file named "data.json" in working space. The content is:

{
    "name": "LittleMoi",
    "age": 18,
    "skill": {
        "JavaScript": 100,
        "CSharp": "$csharp-grade",
        "Java": 50
    } 
}

Prepare the merge data

New the file named "data.merge.json" in working space. We want modify the age and the grade of "Java". So the content of file is:

{
    "$prop": {
        "charp-grade"
    }
    "age": 22,
    "skill": {
        "Java": 120,
        "CSharp": "$charp-grade"
    }
}

Replacement

We hava two options: Manual or Interactive.

Manual Execute the command:

$ json-mergex --src data.json --merge data.merge.json --dst data.merged.json

And we cant checkout the result. It is simple!

Interacitve

$ json-mergex
Find merge file: X:/xxx/data.merge.json
Find src file: X:/xxx/data.json
? The dst path is empty, can you confirm to override the source file? » (Y/n) ...no
Replace: age
Replace: skill.Java
Replace: skill.CSharp
Process any key to continue...

The program will globby with your __dirname, used the pattern "*.merge.json"(This is "data.merge.json"). Then guest the source file's name is "data.json".

About

A command line interface about merging two JSON-Files with replacement in strict mode.

Resources

Stars

Watchers

Forks

Packages

No packages published