PHP Classes

File: README.md

Recommend this page to a friend!
  Classes of Alexey Starikov  >  PHP JSON Maker  >  README.md  >  Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP JSON Maker
Create and edit JSON data setting class variables
Author: By
Last change: add Countable for array
Date: 2 years ago
Size: 2,082 bytes
 

Contents

Class file image Download

jsonMaker

Create JSON easy

Read this in other languages: English.

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;
echo 'code count: ',count($json->address->code);

?????????

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

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

For more information send a message to info at phpclasses dot org.