1. Go to this page and download the library: Download flashport/json-marshaller library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flashport / json-marshaller example snippets
class Person{
// It supports custom property names
#[JsonProperty("fullName")]
public string $name;
// It also supports validation attributes
#[JsonValidateRequired]
public string $email;
// Equals can be a single value or an array
#[JsonValidateEquals(["active", "inactive"])]
public string $status;
// It is necessary to define the array type
#[JsonPropertyType(Address::class)]
public array $addresses;
// For array with scalar types
#[JsonPropertyType(ScalarTypes::INTEGER)]
public array $luckyNumbers;
// The type can be inferred from the property, or from the attribute.
// At least one is
$json = new \JsonMarshaller\JsonMarshaller();
$jsonString = $json->marshal($myObject);
$json = new \JsonMarshaller\JsonMarshaller();
$person = $json->unmarshal($jsonString, Person::class)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.