Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/byjg/php-anydataset-json
Anydataset JSON abstraction. Anydataset is an agnostic data source abstraction layer in PHP.
https://github.com/byjg/php-anydataset-json
anydataset hacktoberfest json json-anydataset json-parser php
Last synced: 3 months ago
JSON representation
Anydataset JSON abstraction. Anydataset is an agnostic data source abstraction layer in PHP.
- Host: GitHub
- URL: https://github.com/byjg/php-anydataset-json
- Owner: byjg
- License: mit
- Created: 2018-11-17T20:51:54.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-12T00:24:13.000Z (4 months ago)
- Last Synced: 2024-10-08T22:06:30.165Z (3 months ago)
- Topics: anydataset, hacktoberfest, json, json-anydataset, json-parser, php
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AnyDataset-Json
[![Build Status](https://github.com/byjg/php-anydataset-json/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-anydataset-json/actions/workflows/phpunit.yml)
[![Opensource ByJG](https://img.shields.io/badge/opensource-byjg-success.svg)](http://opensource.byjg.com)
[![GitHub source](https://img.shields.io/badge/Github-source-informational?logo=github)](https://github.com/byjg/php-anydataset-json/)
[![GitHub license](https://img.shields.io/github/license/byjg/php-anydataset-json.svg)](https://opensource.byjg.com/opensource/licensing.html)
[![GitHub release](https://img.shields.io/github/release/byjg/php-anydataset-json.svg)](https://github.com/byjg/php-anydataset-json/releases/)JSON abstraction dataset. Anydataset is an agnostic data source abstraction layer in PHP.
See more about Anydataset [here](https://opensource.byjg.com/anydataset).
## Concept
The AnyDataset-Json is an abstraction layer to read a JSON data and transform it into a dataset,
and you can manipulate it as a table.Some features:
- Read a JSON file or string
- Define and extract fields
- Validate some elements such as if is required or not, datatype, etc### Example
example.json
```json
{
"menu":{
"header":"SVG Viewer",
"items":[
{
"id":"Open",
"metadata":{
"version":"1",
"date":"NA"
}
},
{
"id":"OpenNew",
"label":"Open New",
"metadata":{
"version":"2",
"date":"2021-10-01"
}
}
]
}
}
```example.php
```php
$json = file_get_contents('example.json');$dataset = new \ByJG\AnyDataset\Json\JsonDataset($json);
$iterator = $dataset->getIterator("/menu/items")
->withFields([
JsonFieldDefinition::create("name", "id"),
JsonFieldDefinition::create("version", "metadata/version")
]);foreach ($iterator as $row) {
echo $row->get('name'); // Print "Open", "OpenNew"
echo $row->get('version'); // Print "1", "2"
}
```## Features
- [The JsonFieldDefinition](docs/jsonfielddefinition.md)
- [Creating dynamic fields](docs/dynamic-fields.md)
- [Simple Manipulation](docs/simple.md)## Install
```
composer require "byjg/anydataset-json"
```## Running the Unit tests
```bash
vendor/bin/phpunit
```## Dependencies
```mermaid
flowchart TD
byjg/anydataset-json --> byjg/anydataset
byjg/anydataset-json --> ext-json
```----
[Open source ByJG](http://opensource.byjg.com)