跳转到主要内容

jsonselect (http://jsonselect.org/) 的Python实现

项目描述

#jsonselect.py

<img src="https://travis-ci.org/mwhooker/jsonselect.png" />

jsonselect.py 是 https://github.com/fd/json_select 的 Python 实现

更多信息请访问 http://jsonselect.org/


## 使用方法

jsonselect 可以直接从命令行调用。

`python -m jsonselect <selector> < jsonfile`

这在解析 JSON API 中的值时非常有用。

```sh
$aws ec2 describe-instances --filters "Name=tag:Name,Values=kafka" | python -m jsonselect .InstanceId
["i-12345678", "i-23456789", "i-3456789A"]
```

### 完整用法

```
用法: __main__.py [-h] [--list | --machine-readable] selector [infile]

使用 jsonselect 解析 JSON。

位置参数
selector
infile

可选参数
-h, --help 显示此帮助信息并退出
--list, -l 以换行符分隔的值列表。在列表上效果最佳。
--machine-readable 不带格式地打印 JSON
```


## 项目状态

jsonselect.py 目前实现了这些一致性测试的 1 & 2 级 https://github.com/lloyd/JSONSelectTests

第 3 级未实现,因为我难以理解正确的行为应该是什么


## 测试

获取上游一致性测试
git submodule update --init

使用以下命令运行特定级别的测试
nosetests -m '.*_level_1' ./tests/test_conformance.py

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

jsonselect-0.2.3.tar.gz (13.6 kB 查看哈希值)

上传时间

由以下支持