UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

23 lines (22 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.json_last_error = json_last_error; const _phpRuntimeState_ts_1 = require("../_helpers/_phpRuntimeState.js"); function json_last_error() { // discuss at: https://phpjs.org/functions/json_last_error/ // parity verified: PHP 8.3 // original by: Brett Zamir (https://brett-zamir.me) // example 1: json_last_error() // returns 1: 0 // JSON_ERROR_NONE = 0 // max depth limit to be removed per PHP comments in json.c (not possible in JS?): // JSON_ERROR_DEPTH = 1 // internal use? also not documented: // JSON_ERROR_STATE_MISMATCH = 2 // [\u0000-\u0008\u000B-\u000C\u000E-\u001F] if used directly within json_decode(): // JSON_ERROR_CTRL_CHAR = 3 // but JSON functions auto-escape these, so error not possible in JavaScript // JSON_ERROR_SYNTAX = 4 // JSON_ERROR_INF_OR_NAN = 7 return (0, _phpRuntimeState_ts_1.getPhpRuntimeNumber)('last_error_json', 0); }