ajayvohra2005/hack-jmespath 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ajayvohra2005/hack-jmespath

Composer 安装命令:

composer require ajayvohra2005/hack-jmespath

包简介

JMESPath search in Hacklang

README 文档

README

Overview

This Hack package allows one to search and extract elements from a JSON document using JMESPath query language.

Requirements

HHVM 4.123 and above.

Installation

  • Git clone this repository

  • Install composer

  • In the root directory of this repository, run the command

      composer install
    

To use this package,

    composer require ajayvohra2005/hack-jmespath

Running Tests

After installation, run the following command in the root directory of this repository:

    ./vendor/bin/hacktest tests/

Example Code

Below is a an example for searching a json document using a JMESPath query expression:

use namespace HackJmesPath;

<<__EntryPoint>>
function jmespath_example(): void {
  require_once(__DIR__.'/../vendor/autoload.hack');
  \Facebook\AutoloadMap\initialize();

    $json = '{
        "people": [
        {
            "name": "Jeff",
            "age": 33,
            "state": {"name": "up"}
        },
        {
            "name": "Bill",
            "age": 51,
            "state": {"name": "down"}
        },
        {
            "name": "Luna",
            "age": 42,
            "state": {"name": "up"}
        }
        ]
    }';

    $espression = "sort_by(people, &age)[].name";
    $result = HackJmesPath\jmespath_search($espression, $json);

    var_dump($result);
}

which produces the following expected output:

vec(3) {
  string(4) "Jeff"
  string(4) "Luna"
  string(4) "Bill"
}

More Examples

See tests/TreeInterpreterTest.hack for a complete list of test cases, and more examples.

Decoding JSON Data Types

JSON 'object' type must be represented by a Hack dict. The stdClass is not supported for a JSON 'object'. This means if you use the Hack built-in function json_decode(), the second argument in the function call must be true so that associative arrays are used.

JMESPath Query Language

Please refer to the in-depth JMESPath Tutorial to learn about JMESPath json query language.

Acknowledgements

The JMESPath package for PHP in-part inspired this code. See individual source files for copyright acknowledgement.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: Hack

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固