---
title: "what the Security and JSON Parser"  
description: "what the Security and JSON Parser"  
author: "AVADHESH PATEL"  
published: 2013-06-06  
updated: 2020-09-15  
canonical: https://www.mindstick.com/interview/1758/what-the-security-and-json-parser  
category: "json"  
tags: ["json"]  
reading_time: 2 minutes  

---

# what the Security and JSON Parser

Security and JSON Parser to understand by below examples \
// Include http://www.json.org/json.js\
var myObject = myJSONtext.parseJSON();\
**eval()** can compile and execute any JavaScript program, so there can be security issues (cross-site scripting) Use eval() when the source can be trusted\
When security is a concern - the source cannot be trusted -, it is better to use a JSON parser A **JSON** parser will only recognize JSON text and so is much safer Object to Text Conversion\
var myJSONText = myObject.toJSONString();\
You can convert JSON object into JSON text\
JSON does not support cyclic data structure\
Do not give cyclical structures to the JSON stringifier

## Answers

### Answer by AVADHESH PATEL

Security and JSON Parser to understand by below examples \
// Include http://www.json.org/json.js\
var myObject = myJSONtext.parseJSON();\
**eval()** can compile and execute any JavaScript program, so there can be security issues (cross-site scripting) Use eval() when the source can be trusted\
When security is a concern - the source cannot be trusted -, it is better to use a JSON parser A **JSON** parser will only recognize JSON text and so is much safer Object to Text Conversion\
var myJSONText = myObject.toJSONString();\
You can convert JSON object into JSON text\
JSON does not support cyclic data structure\
Do not give cyclical structures to the JSON stringifier


---

Original Source: https://www.mindstick.com/interview/1758/what-the-security-and-json-parser

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
