Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
XML
<!DOCTYPE html>
<html>
<head>
<script>
function input(){
   var sResult = '[{"urlName":"ChiroTouch-Accounting-Maintenance","summary":"The maintenance section of the Accounting ribbon allows you to configure site information, providers, payment sources, payers, and trading partners.","label":"ChiroTouch Accounting Maintenance","id":"kA163000000CaXFCA0"},{"urlName":"ChiroTouch-Accounting-Maintenance-Payment-Sources","summary":"When you receive a payment from your payors (such as Aetna, BCBS, etc.) the Accounting application allows you to apply this payment to the patients in the system associated with this payor.","label":"ChiroTouch Accounting Maintenance: Payment Sources","id":"kA163000000CaXACA0"},{"urlName":"ChiroTouch-Meaningful-Use","summary":null,"label":"ChiroTouch Meaningful Use","id":"kA163000000CaXPCA0"},{"urlName":"ChiroTouch-Provider-All-In-One-Toolbar-Overview","summary":"When you first log in to the application, the main screen appears blank. The screen is not yet populated with a patient’s information because you have not yet selected a patient or attempted to call the next patient to the room. However, you do have access to most of the toolbar options located at the top of the screen.","label":"ChiroTouch Provider All-In-One Toolbar Overview","id":"kA163000000CaXjCAK"},{"urlName":"ChiroTouch-Provider-All-In-One-Treatment-Plans","summary":"The Treatment Plan section allows you to create and manage your patient’s treatment plan. Various areas in this section allow you to create and modify your current plan, request an appointment and view the patient’s appointment history.","label":"ChiroTouch Provider All-In-One Treatment Plans","id":"kA163000000CaXoCAK"},{"urlName":"ChiroTouch-Provider-Charges-SALT","summary":null,"label":"ChiroTouch Provider: Charges: SALT","id":"kA163000000CaXZCA0"},{"urlName":"ChiroTouch-Provider-Configuring-Your-Treatment-Notes","summary":"Your Treatment Notes are configurable so that you can set up your treatment note headings in the way that works best for you. To configure yourTreatment Notes setup, click the \"Setup\" button in the lower right-hand corner of the Treatment Notes screen.","label":"ChiroTouch Provider: Configuring Your Treatment Notes","id":"kA163000000CaXeCAK"},{"urlName":"ChiroTouch-Provider-Treatment-Notes","summary":"To enter treatment notes for your patients, click the \"Tx Notes\" button on the Patient Search screen.","label":"ChiroTouch Provider: Treatment Notes","id":"kA163000000CaXUCA0"}]';


console.log('sResult'+'-->' + sResult);
   
	

	
	
	var text1 = JSON.parse(sResult);
	document.forms.form1.area.value = text1;
	}
  
</script>
</head>
<body>
<form name='form1'>
    
    <textarea name='area' rows="12" cols="100" ></textarea>
	
	<input onclick='input()' type='button' value='BUTTON' id='button'>
	

</form>
</body>
</html>


What I have tried:

when we add one more '\' ,then it is work fine.but if we remove one,then it is not work
Posted
Updated 7-Mar-16 0:17am
v2
Comments
Afzaal Ahmad Zeeshan 7-Mar-16 5:33am    
Add '\' where? Can you show us that line which causes the trouble?
Andy Lanng 7-Mar-16 5:53am    
I have formatted the code (OP just didn't have any code tags)
Suvendu Shekhar Giri 7-Mar-16 5:45am    
Format the code correctly.
Andy Lanng 7-Mar-16 5:53am    
I have formatted the code (OP just didn't have any code tags)

1 solution

In Javascript, when you write the literal string:
JavaScript
var s = 'click the \"Setup\" button';

you create a string that contains:
click the "Setup" button


When you pass that string to JSON.parse, it sees the first " as the end of the string. It's then expecting to see a , or a }, as it's reached the end of the property value, but instead it finds the identifier Setup.

You have to escape the \ character so that it's included in the string passed to JSON.parse:
JavaScript
var s = 'click the \\"Setup\\" button';
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900