-
-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Greg Bowler edited this page Mar 28, 2023
·
6 revisions
Throughout PHP.Gt libraries, wherever an object is used to represent data, the DataObject
library is used. Instances of DataObject
provide structured, type-safe, immutable data transfer.
This library extends DataObject
by adding JSON-specific functionality. The main usage will be via the JsonObjectBuilder
class that can be used to build a type of JsonObject
from any JSON string or decoded JSON object from json_decode
.
The purpose of using these classes to represent decoded JSON data is to provide a type-safe, immutable interface to the enclosed data.
The following JSON string is taken from the Stripe API documentation as example data to work with.
$jsonString
:
{
"object": "balance",
"available": [
{
"amount": 2217713,
"currency": "cad",
"source_types": {
"bank_account": 0,
"card": 2217713
}
},
{
"amount": 7254790,
"currency": "gbp",
"source_types": {
"bank_account": 0,
"card": 7254790
}
}
]
}
PHP.Gt/Json is a separately maintained component of PHP.Gt/WebEngine.