2017 © Pedro Peláez
 

library json-query-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

image

estahn/json-query-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

  • Tuesday, March 8, 2016
  • by estahn
  • Repository
  • 2 Watchers
  • 5 Stars
  • 232 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 105 % Grown

The README.md

JSON Query Wrapper

Latest Stable Version Total Downloads Dependency Status SensioLabsInsight Build Status StyleCI, (*1)

json-query-wrapper is a wrapper for the popular command-line JSON processor "jq"., (*2)

Features

  • Easy to use interface
  • PHP data type mapping

Installation

$ composer require estahn/json-query-wrapper

Usage

Basic usage

test.json:, (*3)

{
  "Foo": {
    "Bar": "33"
  }
}

Example 1:, (*4)

$jq = JsonQueryWrapper\JsonQueryFactory::createWith('test.json');
$jq->run('.Foo.Bar'); # string(33)

Example 2:, (*5)

$jq = JsonQueryWrapper\JsonQueryFactory::createWith('test.json');
$jq->run('.Foo.Bar == "33"'); # Returns bool(true)

Example 3:, (*6)

$jq = JsonQueryWrapper\JsonQueryFactory::createWith('{"Foo":{"Bar":"33"}}');
$jq->run('.Foo.Bar == "33"'); # Returns bool(true)

Advanced usage

Example 1:, (*7)

$jq = JsonQueryWrapper\JsonQueryFactory::create();
$jq->setDataProvider(new JsonQueryWrapper\DataProvider\File('test.json');
$jq->run('.Foo.Bar == "33"'); # Returns bool(true)

Data Providers

A "Data Provider" provides the wrapper with the necessary data to read from. It's a common interface for several providers. All providers implement the DataProviderInterface which essentially returns a path to the file for jq., (*8)

Available providers:, (*9)

  • Text - Regular PHP string containing JSON data
  • File - A path to a file containing JSON data

Badge Mania

Build Status Scrutinizer Code Quality Code Coverage Codacy Badge Codacy Badge, (*10)

Alternatives

  • jmespath.php - Declaratively specify how to extract elements from a JSON document, in PHP
  • JSONPath - JSONPath implementation for PHP (based on Stefan Goessner's JSONPath script)

The Versions

08/03 2016

dev-master

9999999-dev https://github.com/estahn/jq-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enrico Stahn

json query jq

07/03 2016

v0.2.1

0.2.1.0 https://github.com/estahn/jq-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enrico Stahn

json query jq

05/03 2016

v0.2.0

0.2.0.0 https://github.com/estahn/jq-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enrico Stahn

json query jq

02/02 2016

v0.1.2

0.1.2.0 https://github.com/estahn/jq-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enrico Stahn

json query jq

02/02 2016

v0.1.1

0.1.1.0 https://github.com/estahn/jq-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enrico Stahn

json query jq

01/02 2016

v0.1.0

0.1.0.0 https://github.com/estahn/jq-wrapper

Wrapper for jq, a lightweight and flexible command-line JSON processor

  Sources   Download

MIT

The Requires

 

The Development Requires

by Enrico Stahn

json query jq