

If the json file and the PHP file accessing it are in the same website, we can use relative path instead of the full file URL. Similar to POST or GET request, we use file_get_contents() but instead of having “php://input”, we use the file path.įor example, if we have a JSON file with path " ", we can access its data as below:
$json = file_get_contents("php://input") įor instance, the JSON data is sent below as a POST request:
#Php json decode obj with nested array how to#
In this post, we will cover how to decode a JSON object and access its data in PHP.īelow is an example of a simple JSON object: It is the most popular and lightweight data-interchange format for web applications, and the de-facto format for the data exchange in RESTful web services requests and responses. It is easy to generate and parse in many programming languages. Java Script Object Notation( JSON) is a lightweight human-readable text format for storing and transporting data consisting of name-value pairs and arrays. John Mwaniki / How to extract and access JSON data in PHP What is JSON?
