JSON.isRawJSON
Determines whether a value is an object returned by JSON.rawJSON
Syntax
JSON.isRawJSON(value)Parameters
| Parameter | Type | Description |
|---|---|---|
| value | any | The value to check |
Return Value
true if the value is a raw JSON object, false otherwise
Examples
const raw = JSON.rawJSON('42');
console.log(JSON.isRawJSON(raw)); // true
console.log(JSON.isRawJSON(42)); // falsefunction customStringify(obj: Record<string, unknown>) {
for (const [key, val] of Object.entries(obj)) {
if (JSON.isRawJSON(val)) {
console.log(`${key} is raw JSON`);
}
}
return JSON.stringify(obj);
}console.log(JSON.isRawJSON(null)); // false
console.log(JSON.isRawJSON({})); // false
console.log(JSON.isRawJSON(JSON.rawJSON('true'))); // trueUnderstanding JSON.isRawJSON
The JSON.isRawJSON method in JavaScript determines whether a value is an object returned by JSON.rawJSON. It belongs to the JSON object and is one of the most widely used methods for working with json values in modern JavaScript and TypeScript applications.
The method signature is JSON.isRawJSON(value). It accepts 1 parameter: value. When called, it returns true if the value is a raw json object, false otherwise. Understanding when and how to use isRawJSON() helps you write more expressive, readable code.
Common use cases for JSON.isRawJSON include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like json-rawjson, json-parse, json-stringify, enabling you to chain operations together for complex data manipulation pipelines.
Supported in Chrome 114+, Firefox 135+, and Node.js 22+. Safari support is pending.
Browser Compatibility
Supported in Chrome 114+, Firefox 135+, and Node.js 22+. Safari support is pending.
Related Methods
JSON.rawJSONCreates a raw JSON object that can be included in a JSON string without being re-serialized
JSON.parseParses a JSON string, constructing the JavaScript value or object described by the string
JSON.stringifyConverts a JavaScript value to a JSON string, optionally replacing values or including only specified properties
More JSON Methods
Other methods in the JSON object
Related Tools
More JSON Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.