PHP Classes
elePHPant
Icontem

PHP JSON Maker: Create and edit JSON data setting class variables

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-08-10 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 246 This week: 109All time: 7,573 This week: 4Up
Version License PHP version Categories
jsonmaker 1.0Custom (specified...5.4PHP 5, Text processing, Data types
Description Author

This class can be used to create and edit JSON data setting class variables.

It can compose JSON data structures by setting class objects variables.

Evaluating the object will return the whole data structured encoded as JSON.

Innovation Award
PHP Programming Innovation award nominee
August 2017
Nominee
Vote
JSON is nowadays very common format to store typed information in strings.

When you have a complex object structure, usually it is necessary to create the top level object and each child object one by one.

This package makes that task simpler by allowing to create multiple nested objects using a single command.

Manuel Lemos
  Performance   Level  
Name: Alexey Starikov <contact>
Classes: 1 package by
Country: Russian Federation Russian Federation
Age: 40
All time rank: 3775104 in Russian Federation Russian Federation
Week rank: 6 Up1 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 1x

Details

jsonMaker

Create JSON easy

PHP ????? ??? ???????? ? ??????????? ????????? ?????? ? ??????? JSON

?????????

composer require alexsuperstar/jsonmaker

???????? JSON

$a = new \alexstar\JsonMaker();
$cc='xyz';
$a->{$cc}->bbb->cccc[0]->xxx=5;
$a->{$cc}->zz='qq';
$a->xyz->zf='qq';
$a->xx->zz='qq';
echo $a; 

?????????

{"xyz":{"bbb":{"cccc":[{"xxx":5}]},"zz":"qq","zf":"qq"},"xx":{"zz":"qq"}}

?????????????? JSON

???????? JSON

{
  "firstName": "????",
  "lastName": "??????",
  "address": {
    "streetAddress": "?????????? ?., 101, ??.101",
    "city": "?????????",
    "postalCode": 101101
  },
  "phoneNumbers": [
    "812 123-1234",
    "916 123-4567"
  ]
}

PHP ???

<?php 
$loader = require_once __DIR__ . '/vendor/autoload.php';
$json = new \alexstar\JsonMaker('{"firstName":"????","lastName":"??????","address":{"streetAddress":"?????????? ?., 101, ??.101","city":"?????????","postalCode":101101},"phoneNumbers":["812 123-1234","916 123-4567"]}');
$json->firstName='???????';
$dom='???';
$json->address->{$dom}=6;
$json->address->code[]='123';
$json->address->code[]='456';
$json->phoneNumbers[2]='+7(123)1233-45-67';
unset($json->address->city,$json->phoneNumbers[0]);
echo $json;

?????????

{
  "firstName": "???????",
  "lastName": "??????",
  "address": {
    "streetAddress": "?????????? ?., 101, ??.101",
    "postalCode": 101101,
    "???": 6,
    "code": [
      "123",
      "456"
    ]
  },
  "phoneNumbers": {
    "1": "916 123-4567",
    "2": "+7(123)1233-45-67"
  }
}

PS: ?? ?????? ???????????? ?????? ?????? ??????? ?? ????, ????? ??? ?????????? ?? ??????? ?? ? ?? ??????.

  Files folder image Files  
File Role Description
Files folder imagesrc (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imagealexstar (1 file)

  Files folder image Files  /  src  /  alexstar  
File Role Description
  Plain text file JsonMaker.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:246
This week:109
All time:7,573
This week:4Up