{"id":20180741,"url":"https://github.com/webfiori/json","last_synced_at":"2025-10-29T03:07:54.764Z","repository":{"id":40394042,"uuid":"123592521","full_name":"WebFiori/json","owner":"WebFiori","description":"A JSON helper classes for creating JSON strings in PHP.","archived":false,"fork":false,"pushed_at":"2025-01-28T20:00:15.000Z","size":302,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T05:09:10.663Z","etag":null,"topics":["apis","hacktoberfest","json","json-parser","php","php-library","webfiori-framework"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebFiori.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://paypal.me/IbrahimBinAlshikh","https://www.buymeacoffee.com/ibrahimdev"],"ko_fi":"ibrahimdev"}},"created_at":"2018-03-02T14:58:47.000Z","updated_at":"2025-01-28T19:59:05.000Z","dependencies_parsed_at":"2023-12-10T20:25:47.650Z","dependency_job_id":"18aa0a76-991b-4557-95ae-36cb74215002","html_url":"https://github.com/WebFiori/json","commit_stats":{"total_commits":286,"total_committers":3,"mean_commits":95.33333333333333,"dds":0.05944055944055948,"last_synced_commit":"36f6759c4c998080fb34d92d87ec66e29b840caf"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Fjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebFiori","download_url":"https://codeload.github.com/WebFiori/json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161272,"owners_count":21057555,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apis","hacktoberfest","json","json-parser","php","php-library","webfiori-framework"],"created_at":"2024-11-14T02:32:40.325Z","updated_at":"2025-10-29T03:07:54.475Z","avatar_url":"https://github.com/WebFiori.png","language":"PHP","funding_links":["https://paypal.me/IbrahimBinAlshikh","https://www.buymeacoffee.com/ibrahimdev","https://ko-fi.com/ibrahimdev"],"categories":[],"sub_categories":[],"readme":"# WebFiori Json\n\nA helper class library for creating JSON or JSONx strings in PHP. It can be used to create well-formatted json strings from any variable type (strings, numbers, boolean arrays and even objects).\n\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/json/actions/workflows/php84.yml\"\u003e\n    \u003cimg src=\"https://github.com/WebFiori/json/actions/workflows/php84.yml/badge.svg?branch=master\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/WebFiori/json\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/WebFiori/json/branch/master/graph/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://sonarcloud.io/dashboard?id=WebFiori_json\"\u003e\n      \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=WebFiori_json\u0026metric=alert_status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://packagist.org/packages/webfiori/jsonx\"\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/dt/webfiori/jsonx?color=light-green\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# Content\n* [What is JSON?](what-is-json)\n* [Features](#features)\n* [Supported PHP Versions](#supported-php-versions)\n* [Installation](#installation)\n* [Code Samples](#code-samples)\n* [Basic Usage](#basic-usage)\n  * [Example](#example)\n* [Converting Properties Case](#converting-properties-case)\n* [Reading From Files](#reading-from-files)\n* [Working With Objects](#working-with-objects)\n* [Decoding JSON String](#decoding-json-string)\n* [Storing Output](#storing-output)\n* [Working With Arrays](#working-with-arrays)\n* [JSONx](#jsonx]\n\n## What is JSON?\n\nAccording to [json.org](https://www.json.org/json-en.html), JSON is a data exchange format which is based partially on JavaScript. It is easy for humans to read and for machines to understand. JSON data is represented as pairs of keys and values.\n\n## Features\n* Support fo creating well formatted JSON.\n* Support for creating [JSONx](https://www.ibm.com/docs/en/datapower-gateways/10.0.1?topic=20-jsonx).\n* Ability to decode JSON strings and convert them to `Json` objects.\n* Ability to read JSON files and map JSON values to PHP data types.\n* Ability to manipulate JSON properties as needed.\n\n## Supported PHP Versions\n|                                                                                        Build Status                                                                                         |\n|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/json/actions/workflows/php80.yml\"\u003e\u003cimg src=\"https://github.com/WebFiori/json/actions/workflows/php80.yml/badge.svg?branch=master\"\u003e\u003c/a\u003e |\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/json/actions/workflows/php81.yml\"\u003e\u003cimg src=\"https://github.com/WebFiori/json/actions/workflows/php81.yml/badge.svg?branch=master\"\u003e\u003c/a\u003e |\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/json/actions/workflows/php82.yml\"\u003e\u003cimg src=\"https://github.com/WebFiori/json/actions/workflows/php82.yml/badge.svg?branch=master\"\u003e\u003c/a\u003e |\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/json/actions/workflows/php83.yml\"\u003e\u003cimg src=\"https://github.com/WebFiori/json/actions/workflows/php83.yml/badge.svg?branch=master\"\u003e\u003c/a\u003e |\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/json/actions/workflows/php84.yml\"\u003e\u003cimg src=\"https://github.com/WebFiori/json/actions/workflows/php84.yml/badge.svg?branch=master\"\u003e\u003c/a\u003e |\n\n## Installation\nIf you are using composer to manage your dependencies, then it is possible to install the library by including the entry `\"webfiori/jsonx\":\"*\"` in the `require` section of your `composer.json` file to install the latest release. \n\nAnother way to include the library is by going to [releases](https://github.com/WebFiori/json/releases) and download the latest release and extract compressed file content and add them to your include directory.\n\n## Basic Usage\nThe process of using the classes is very simple. What you have to do is the following steps:\n\n  * Import (or include) the class [`Json`](https://github.com/WebFiori/json/blob/master/webfiori/json/Json.php).\n  * Create an instance of the class.\n  * Add data as needed.\n  * Output the object using `echo` command or any similar one.\n\nFor more information and advanced use cases, check [here](https://webfiori.com/learn/webfiori-json).\n\n### Example\nThe following code shows a very simple usage example.\n\n```php\n//load the class \"Json\"\nrequire_once 'Json.php';\nuse webfiori\\json\\Json;\n\n//initialize an object of the class Json\n$j = new Json();\n\n//add a number attribute\n$j-\u003eaddNumber('my-number', 34);\n\n//add a boolean with 'false' as its value. \n$j-\u003eaddBoolean('my-boolean', false);\n\n//add a string\n$j-\u003eaddString('a-string', 'Hello, I\\'m Json! I like \"JSON\". ');\n\nheader('content-type:application/json');\n/*\nsend back the generated json string.\nThe output of the code will be like that:\n{\n    \"my-number\":34,\n    \"my-boolean\":false,\n    \"my-number\":\"Hello, I'm Json! I like \\\"json\\\". \",\n}\n*/\necho $j;\n```\n\nFollowing example shows how data can be added directly using the constructure.\n\n``` php\n$jsonObj = new Json([\n    'first-name' =\u003e 'Ibrahim',\n    'last-name' =\u003e 'BinAlshikh',\n    'age' =\u003e 26,\n    'is-married' =\u003e true,\n    'mobile-number' =\u003e null\n]);\n```\n\nThe JSON output of this code will be the following:\n\n``` json\n{\n    \"first-name\":\"Ibrahim\",\n    \"last-name\":\"BinAlshikh\",\n    \"age\":26,\n    \"is-married\":true,\n    \"mobile-number\":null\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfiori%2Fjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebfiori%2Fjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfiori%2Fjson/lists"}