What is json in php with example

| Last Updated: | In: PHP Tutorial


JSON ( JavaScript Object Notation ), is an open standard format that uses human-readable text to transmit data objects. The JSON standard only supports when you are using inside an array or an object in your web applications. There are the native functions in php language to encode and decode your JSON data.

You can encode your data in JSON format using the ” json_encode() ” function and decode your data using json_decode() function.

json_logo-555px

Example (A) json_encode() example

The above example will output:

Example (B) json_decode() examples

The above example will output:

Data types, syntax and example

The following example shows the JSON representation. The object has string fields for first name and last name, age, an object representing the person’s address and phone number objects.


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby.


You may also like:


, , , , , , , , , , , , ,