Coder Social home page Coder Social logo

jsonfind's Introduction

JSON(python dict) finder

Install

  • pip install jsonfind

CLI

# jsonfind
Usage: jsonfind [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  find-any
  find-by
  find-eq
  find-is
  find-key
  find-regex
  find-subset

# jsonfind find-any --help
Usage: jsonfind find-any [OPTIONS] [OBJ]

Options:
  --verbose / --no-verbose
  --target TEXT                   query(JSON string)  [required]
  --format [jsonpath|jsonpointer]
  --key [eq|is|in1|in2|match|sub|eval|fnmatch|range]
  --value [eq|is|in1|in2|match|sub|eval|fnmatch|range]
  --mode [sub|super|set]
  --help                          Show this message and exit.
  • jo hello=world a=$(jo b=$(jo c=d))
    • {"hello":"world","a":{"b":{"c":"d"}}}
  • jo hello=world a=$(jo b=$(jo c=d)) | jsonfind find-eq --target $(jo c=d) --format jsonpointer
    • ["/a/b"]
  • jo hello=world a=$(jo b=$(jo c=d)) | ./bin/jsonfind find-eq --target $(jo c=d) --format jsonpath
    • ["a.b"]
  • jo hello=world a=$(jo b=$(jo c=d)) | ./bin/jsonfind find-by --format jsonpointer --query /a/b
    • {"c": "d"}
  • jo hello=world a=$(jo b=$(jo c=d)) | ./bin/jsonfind find-by --format jsonpath --query a.b
    • [{"c": "d"}]

Python

>>> from jsonfind import JsonFind
>>> obj = {"a":"b","c":{"d":"e"}}
>>> tgt = obj["c"]
>>> JsonFind.to_jsonpointer(JsonFind.find_eq(obj, tgt))
'/c'
>>> JsonFind.to_jsonpath(JsonFind.find_eq(obj, tgt))
'c'

links

jsonfind's People

Contributors

wtnb75 avatar

Watchers

 avatar  avatar  avatar

jsonfind's Issues

探し方のバリエーション

  • 部分一致
  • 正規表現
  • glob
  • 数値の範囲

keyとvalueについてそれぞれ比較のやり方を設定できるといいと思った。
keyに==isを使ったときに性能が落ちないように気をつけたいところ。

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.