sobernt / jq-object
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
pkg:composer/sobernt/jq-object
Requires
- php: ^7.2
- ext-jq: *
- ext-json: *
This package is auto-updated.
Last update: 2025-10-24 07:50:00 UTC
README
Install
do install instructions for requrement package: https://github.com/kjdev/php-ext-jq
install this package via composer:
composer require sobernt/jq-object
Usage
init object with minimal params:
$obj = new sobernt\JqObject\JqObject("{
\"testkey\":\"testval\",
\"testarray\":[
\"testsimplearrayval1\",
\"testsimplearrayval2\"
],
\"testcompositearray\":[
\"testcompositearrayval1\",
{
\"testcompositearray2key\": \"testcompositearray2value\"
}
],
\"testobject\":{
\"testobjectkey\": \"testobjectval\",
\"testobjectintkey\": \"1\"
}
}");
full constructor:
__construct(string $json,bool $is_formatted=true,$depth=0,$max_depth=255)
set $is_formated=false for get all primitives as string.
set $max_depth = 500 for reconfigure object max recursion level = 500
throws InstallJqException if jq not installed
throws JsonException if json can't be parse
throws JQException on all other service errors\php warnings in class.
you can use this as default object from json_encode, but json parse by parts if you use this syntax:
$obj->testobject
this example return array:
$obj->testarray
this example returns object:
$obj->testcompositearray[1]
this example returns string if $is_formated=false else (int)1:
$obj->testobject->testobjectintkey
throws InvalidArgumentException if you call object not founded in json