has()
Check whether a path exists in the document.
Signature
php
JsonFast::has(string $json, string $path): boolParameters
| Name | Type | Description |
|---|---|---|
$json | string | JSON document |
$path | string | Dot/bracket path (same rules as get()) |
Returns
true if the path exists; false otherwise.
Distinguishes “path missing” from “value is JSON null” — unlike relying on get() alone.
Examples
php
$json = '{"user":{"name":"Allan","optional":null}}';
JsonFast::has($json, 'user.name'); // true
JsonFast::has($json, 'user.optional'); // true (key exists, value is null)
JsonFast::has($json, 'user.missing'); // falseConditional reads:
php
if (JsonFast::has($config, 'features.beta')) {
enableBeta(JsonFast::get($config, 'features.beta'));
}