Орла
Области
Компаний
Пользователи
Галерея
Фиксированные новости
Орла
Отзывы о фирмах
Тарифы
Пользователи
Области
Банкоматы
Торговые точки
Доска объявлений
Курсы валют
Скидки
организации Орла
организации области
товары
сайты
сайты Орел
Данные
Разделы
Поиск
Поиск запросы
Статистика
Показы каталога организаций
Статистика клиенты
Пользователи
Сайты
Управление сайтом
Анкета
Аптеки
Афиша
Афиша новая
Баннеры
Бизнес >
Викторина
Голосование
Гость на сайте
Истории
Календарь событий
Каталоги >
Конкурс красоты
Конкурс аудио
Консультации
Меню
Новое на сайте
Новости >
Организации >
Программа ТВ
Публикации
Разделы сайта
Рассылка
Рестораны
Секрет фирмы >
Сервисы >
Ссылки
Тесты
Файловый менеджер
Форум
Фотогалерея
Обратная связь
Недвижимость
Новый год
Тексты
Пользователи
Юридический рейтинг
Отзывы на товары
Бан пользователей
Жалобы
Новые тесты
Коронавирус
Файловый менеджер
Имя файла
basic_example.php
Содержимое
<?php require __DIR__.'/../vendor/autoload.php'; use LazyJsonMapper\LazyJsonMapper; /* * Imagine the following JSON, which you want an object-oriented interface for: */ $section_json = <<<EOF { "section_title": "Employees", "users": [ { "name": "Edmund McMundensson", "details": { "age": 32, "hired_date": "2014-02-28" } }, { "name": "Mabe Mabers", "details": { "age": 50, "hired_date": "2000-05-12" } } ] } EOF; /* * Here are some PHP classes to represent that data structure as objects: */ class Section extends LazyJsonMapper { const JSON_PROPERTY_MAP = [ 'section_title' => 'string', 'users' => 'User[]', ]; } class User extends LazyJsonMapper { const JSON_PROPERTY_MAP = [ 'name' => 'string', 'details' => 'UserDetails', ]; } class UserDetails extends LazyJsonMapper { const JSON_PROPERTY_MAP = [ 'age' => 'int', 'hired_date' => 'string', ]; } /* * Now simply create the root object (a Section), and give it the section JSON: */ $section = new Section(json_decode($section_json, true)); /* * Here's how you would look at the available properties and their functions: */ $section->printPropertyDescriptions(); /* * Now let's access some data, via the functions shown by the previous command. */ printf("\n\nData Output Example:\n\nSection Title: %s\n", $section->getSectionTitle()); foreach ($section->getUsers() as $user) { // $user->printPropertyDescriptions(); // Uncomment to see User-functions. // $user->printJson(); // Uncomment to look at the JSON data for that user. printf( "- User: %s\n Age: %s\n Hired Date: %s\n", $user->getName(), $user->getDetails()->getAge(), $user->getDetails()->getHiredDate() ); } echo "\n\n"; /* * Lastly, let's demonstrate looking at the actual internal JSON data: */ // var_dump($section->asJson()); // Uncomment to get a JSON data string instead. // var_dump($section->getUsers()[0]->asJson()); // Property sub-object encoding. // var_dump(json_encode($section->getUsers())); // Property non-object values // // solvable via `json_encode()`. $section->printJson(); /* * There are a million other functions and features. Have fun exploring! * Simply read the main src/LazyJsonMapper.php file for all documentation! */
/cron/instagram/vendor/lazyjsonmapper/lazyjsonmapper/examples/
Имя
Дата
Размер
..
2019-01-15
basic_example.php
2019-01-15
2 кб.
import_example.php
2019-01-15
1005 байт
inheritance_example.php
2019-01-15
926 байт
unpredictable_data.php
2019-01-15
24 кб.
/cron/instagram/vendor/lazyjsonmapper/lazyjsonmapper/examples
Загрузить файлы
Файл 1
Файл 2
Файл 3