brainplusplus/php-jsonpath

JSONPath 库和辅助工具

1.0.0 2017-10-28 05:49 UTC

This package is not auto-updated.

Last update: 2024-09-19 17:59:13 UTC


README

https://code.google.com/archive/p/jsonpath 分支

并添加 JsonPathHelper 类

如何使用

$url = "https://api-ssl.bitly.com/v3/link/referrers?access_token=xxxxx&link=http://bit.ly/xxxxx";

例如,该 URL 中的 json 为

{"status_code": 200, "data": {"units": -1, "unit_reference_ts": null, "tz_offset": -4, "unit": "day", "referrers": [{"referrer": "https://#/", "clicks": 111}, {"referrer": "direct", "clicks": 99}, {"referrer": "android-app://com.twitter.android", "clicks": 81}, {"referrer": "/android-app://com.twitter.android", "clicks": 2}]}, "status_txt": "OK"}

..referrers.*";

echo "

示例:获取 JSON 字符串值

; $result = JsonPathHelper::getJsonStringValueByUrl($url,$expr); echo $result;

echo "

示例:获取 JSON 字符串路径

; $result = JsonPathHelper::getJsonStringPathByUrl($url,$expr); echo $result;

echo "

示例:获取 JSON 对象

; $result = JsonPathHelper::getJsonValueByUrl($url,$expr); var_dump($result);