Field Manual PHP / Laravel reference
← HTTP / API

JSON

JSON is a text format for structured data.

What it is

JSON is a text format for structured data.

When to use it

Exchange deliberate machine-readable payloads.

Syntax

{"amount_cents":1250,"currency":"USD","reference":null}

Example

// PHP parsing:
$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
// Laravel normally parses application/json request bodies:
$data = $request->validate(["amount_cents" => "required|integer|min:1"]);

Common mistakes

Malformed JSON and invalid business values differ; encode identifiers as strings when they exceed consumer integer precision.

Related topics

JSON