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.

Tags: , , , , , , , , , , , , ,


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:

Get Free Access of 450+ Scripts

Don't worry you'll not be spammed!

Featured eBook

WordPress Security Guide

Free Guide: Learn how to implement security guideline in your WordPress site...

DOWNLOAD

Free WordPress Setup Service

Free WordPress Setup

Want to Setup WordPress Blog Setup? I will help you in the setup of your WordPress blog.

Click Here

Discount Coupons

Pincode Finder

pincode-finder tool

Online Pincode Finder

Best tool to locate post Office address and pincodes of all india...

SEARCH NOW