Usually, you would do something like this:

$post_data = json_encode(array('item' => $post_data));

But, as it seems you want the output to be with "{}", you better make sure to force json_encode() to encode as object, by passing the JSON_FORCE_OBJECT constant.

$post_data = json_encode(array('item' => $post_data), JSON_FORCE_OBJECT);

"{}" brackets specify an object and "[]" are used for arrays according to JSON specification.

Answer from Cristian on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ php โ€บ php_json.asp
PHP and JSON
PHP has some built-in functions to handle JSON. First, we will look at the following two functions: ... The json_encode() function is used to encode a value to JSON format. This example shows how to encode an associative array into a JSON object:
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ book.json.php
PHP: JSON - Manual
This extension implements the ยป JavaScript Object Notation (JSON) data-interchange format. PHP comes with a parser that is specifically written for PHP and licensed under the PHP license.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ php-tutorial โ€บ how to create json objects in php
How to Create JSON Objects in PHP - Scaler Topics
April 14, 2024 - In PHP, JSON object serialization refers to the process of converting PHP objects into a JSON format. This is commonly used when you want to store or transmit PHP objects in a standardized, human-readable format.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ json โ€บ json_php_example.htm
JSON with PHP
PHP json_encode() function is used for encoding JSON in PHP. This function returns the JSON representation of a value on success or FALSE on failure. ... options โˆ’ This optional value is a bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, ...
๐ŸŒ
Nidup
nidup.io โ€บ blog โ€บ manipulate-json-files-in-php
Read, Decode, Encode, Write JSON in PHP | Nicolas Dupont
March 12, 2022 - We use json_decode to convert (decode) the string to a PHP associative array. The second parameter of json_decode specifies if we want to get each JSON object as an associative array or as an object.
๐ŸŒ
PHP Tutorial
phptutorial.net โ€บ home โ€บ php oop โ€บ php json
An Essential Guide to PHP JSON - PHP Tutorial
July 21, 2021 - A collection of name/value pairs called JSON objects. JSON objects are equivalent to associative arrays in PHP.
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-convert-a-string-to-json-object-in-php
How to Convert a String to JSON Object in PHP ? - GeeksforGeeks
July 23, 2025 - The json_decode() function is a versatile and commonly used method to convert a JSON-formatted string into a PHP object.
๐ŸŒ
Scout APM
scoutapm.com โ€บ home โ€บ blog โ€บ php json_encode: serialize php objects to json
PHP Json_encode: Serialize PHP Objects to JSON | Scout Monitoring
May 1, 2020 - Since the information in JSON is stored in key/value pairs,*** json_encode()*** is more likely to be used to encode PHP objects and their instance variables.
๐ŸŒ
Alex Web Develop
alexwebdevelop.com โ€บ home โ€บ php json complete tutorial (with examples)
PHP JSON complete tutorial (with examples) - Alex Web Develop
November 8, 2022 - This is the definitive PHP JSON tutorial. Learn how to encode and decode JSON objects, set the JSON content-type, JSON validation and more. Examples included.
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ php-tutorial โ€บ php-json-parsing.php
How to Encode and Decode JSON Data in PHP - Tutorial Republic
As you can see in the above examples a non-associative array can be encoded as array or object. However, an associative array always encoded as object. Decoding JSON data is as simple as encoding it. You can use the PHP json_decode() function to convert the JSON encoded string into appropriate PHP data type.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-parse-a-json-file-in-php
How to parse a JSON File in PHP? - GeeksforGeeks
The json_decode() function is used to convert the JSON string into a PHP array or object.
Published: June 24, 2025
๐ŸŒ
ReqBin
reqbin.com โ€บ code โ€บ php โ€บ 4qfsaffq โ€บ php-json-encode-example
How do I encode a PHP object to JSON string?
July 5, 2023 - To encode a PHP object to a JSON formatted string, you can use the json_encode($value, $options, $depth) function. The $value parameter specifies the PHP object to encode.
๐ŸŒ
CodeSignal
codesignal.com โ€บ learn โ€บ courses โ€บ handling-json-files-with-php โ€บ lessons โ€บ parsing-and-accessing-json-data-with-php
Parsing and Accessing JSON Data with PHP
This lesson will focus on using ... environment. Before parsing a JSON file, let's briefly revisit JSON's hierarchical structure. JSON consists of key-value pairs, objects, and arrays....
๐ŸŒ
Jobtensor
jobtensor.com โ€บ Tutorial โ€บ PHP โ€บ en โ€บ JSON
PHP JSON - json_encode(), json_decode() | jobtensor
<?php $countries = array("Mark" => "USA", "Raymond" => "UK", "Jeff" => "JPN", "Mike" => "DE"); echo json_encode($countries); The json_decode() function is used to decode a JSON object into a PHP associative array or object.
๐ŸŒ
Jsontophp
jsontophp.com
Convert JSON Object to PHP Array Online
JSON to PHP array converter online - Convert the given JSON object or Array into beautified PHP array that can be used instantly into your PHP file as a PHP array