Skip to content

Commit

Permalink
update readme with key types
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharat23 committed May 21, 2020
1 parent 397eb1f commit 06b33cd
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
75 changes: 75 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [Prerequiste](#prerequiste)
* [Installation](#installation)
* [Examples](#example)
* [Key Types](#key-type)
- ## [Available Methods](#available-methods)

## Getting Started
Expand All @@ -30,6 +31,80 @@
JSONParser(test_json).pick(keys=keys).exec()
```
- ### Key Types:
- #### key_name
- Works like simple JSON extraction. Provide the name of the key and boom!.
- For extraction from beyond first level, append keys with a separator and provide `key_delimiter` for the program to recognize the start of next level.
- Example:
```
"""
{
keylevel11: {
keylevel21: value,
keylevel22: {
keylevel31: value
}
}
}
"""
# key to extract first level
# keylevel11
# returns {keylevel21: ...}
# key to extract second level, first key
# keylevel11.keylevel21
# returns value
```
- #### [list_index]
- When you have a list as value and you want to extract a specific index value/object.
- For extraction from beyond first level, append keys with a separator and provide `key_delimiter` for the program to recognize the start of next level.
- Example:
```
"""
{
keylevel11: {
keylevel21: [
1, 2, 3
],
keylevel22: {
keylevel31: value
}
}
}
"""
# key to extract second level, third index
# keylevel11.keylevel21.[2]
# returns 3
```
- #### [{key=value}]
- When you have a unordered list of object and you want extract a specific object from the list based on the key and value inside the object
- For extraction from beyond first level, append keys with a separator and provide `key_delimiter` for the program to recognize the start of next level.
- Example:
```
"""
{
keylevel11: {
keylevel21: [
1, 2, 3
],
keylevel22: {
keylevel31: value
},
keylevel23: [
{
name: Awesome,
},
{
name: Package
}
]
}
}
"""
# key to extract second level, and from that extarct the object with name = Awesome
# keylevel11.keylevel23.[{name=Awesome}]
# return {name: Awesome}
```
### Available Methods
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def read(fname):
url="https://github.com/Bharat23/wpt-parser",
packages=setuptools.find_packages(),
license='MIT',
keywords = ['WPT parser', 'wpt', 'speed curve', 'webpagetest'],
keywords = ['WPT parser', 'wpt', 'speed curve', 'webpagetest', 'json'],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit 06b33cd

Please sign in to comment.