The JSON.isRawJSON() method tests whether a given value is an object returned by JSON.rawJSON(). This method is useful for identifying raw JSON objects.
The syntax of JSON.isRawJSON() static-method is:
JSON.isRawJSON(value)
This isRawJSON() static-method of JSON tests whether a value is an object returned by JSON.rawJSON().
Parameter | Optional/Required | Description |
---|---|---|
value | required | The value to be tested if it is an object returned by JSON.rawJSON(). |
JSON.isRawJSON() returns value of type Boolean
.
In JavaScript, we can use the JSON.isRawJSON()
method to check if a given value is a raw JSON object.
For example,
raw
using JSON.rawJSON()
method.JSON.isRawJSON()
method to test if raw
is a raw JSON object.isRaw
.isRaw
to the console using console.log()
method.const raw = JSON.rawJSON({ key: 'value' });
const isRaw = JSON.isRawJSON(raw);
console.log(isRaw);
true
In JavaScript, we can use the JSON.isRawJSON()
method to check if a given value is not a raw JSON object.
For example,
obj
with a key-value pair.JSON.isRawJSON()
method to test if obj
is a raw JSON object.isRaw
.isRaw
to the console using console.log()
method.const obj = { key: 'value' };
const isRaw = JSON.isRawJSON(obj);
console.log(isRaw);
false
In JavaScript, we can use the JSON.isRawJSON()
method to check if a string value is a raw JSON object.
For example,
str
with a value.JSON.isRawJSON()
method to test if str
is a raw JSON object.isRaw
.isRaw
to the console using console.log()
method.const str = 'Hello, World!';
const isRaw = JSON.isRawJSON(str);
console.log(isRaw);
false
In this JavaScript tutorial, we learned about isRawJSON() static-method of JSON: the syntax and few working examples with output and detailed explanation for each example.