Use a JSON parser like JSON.parse
:
function isJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
More Related Contents:
- Convert JS object to JSON string
- How to read an external local JSON file in JavaScript?
- Javascript object Vs JSON
- Using setTimeout on promise chain
- Parsing JSON objects for HTML table
- How to parse JSON to receive a Date object in JavaScript?
- Why is it a bad practice to return generated HTML instead of JSON? Or is it?
- Array.push() if does not exist?
- Why does JavaScript’s eval need parentheses to eval JSON data?
- Deserializing a JSON into a JavaScript object
- Map HTML to JSON [closed]
- Serializing an object to JSON
- Convert javascript object or array to json for ajax data
- Using Fetch API to Access JSON
- How to access nested JSON data
- Javascript search inside a JSON object
- Express and ejs
- Defining a HTML template to append using JQuery
- Nested JSON objects – do I have to use arrays for everything?
- Separate Angular2 TypeScript files and JavaScript files into different folders, maybe ‘dist‘
- Chrome and IE sorts JSON Object automatically, how to disable this?
- JSON.stringify output to div in pretty print way
- Is it possible to rename a key in the Firebase Realtime Database?
- Remove JSON element
- JSON.stringify converting Infinity to null
- Remove key-value pair from JSON object
- How to restore original object/type from JSON?
- Cross-Origin resource sharing and file://
- sending data as JSON object from Python to Javascript with Jinja [duplicate]
- Process a continuous stream of JSON