Oihana PHP Enums

JsonParam uses ConstantsTrait

Enumeration of common parameter names used in JSON encoding and decoding operations.

This class defines string constants representing typical options passed to JSON functions such as json_encode() and json_decode() in PHP.

These keys correspond to:

  • associative: Determines if JSON objects should be decoded as associative arrays.
  • depth: Sets the maximum recursion depth for encoding or decoding.
  • flags: Defines bitmask flags to modify the behavior of JSON operations.

Example usage:

use oihana\enums\JsonParam;

$option = [
    JsonParam::ASSOCIATIVE => true,
    JsonParam::DEPTH       => 512,
    JsonParam::FLAGS       => JSON_PRETTY_PRINT,
];
Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Constants

ASSOCIATIVE  : string = 'associative'
DEPTH  : string = 'depth'
FLAGS  : string = 'flags'
JSON_NONE  : int = 0
Indicates the default 'no' json options.

Methods

getDefaultValues()  : array<string, mixed>
Returns default values for JSON parameters.
isValidFlags()  : bool
Checks if the given flags value is valid JSON flag or combination of flags.

Constants

ASSOCIATIVE

public string ASSOCIATIVE = 'associative'

JSON_NONE

Indicates the default 'no' json options.

public int JSON_NONE = 0

Methods

getDefaultValues()

Returns default values for JSON parameters.

public static getDefaultValues() : array<string, mixed>
Return values
array<string, mixed>

isValidFlags()

Checks if the given flags value is valid JSON flag or combination of flags.

public static isValidFlags(int $flags) : bool

You may add more flags as needed.

Parameters
$flags : int
Return values
bool
On this page

Search results