Escape characters output by JSON Array?

L

laredotornado

Hi,

I'm inserting some text on a JSF page using

var treeModel = {identifier: 'id',label: 'label',
items: <h:eek:utputText value='#{AddApplicationPage.applications}'
escape='false'/>

where the "getApplication" method returns the "toString()" method of a
JSONArray object:

JSONArray applications;
/* applications var is populated */
rtn = applications.toString().replaceAll("\"", "");
return rtn;

Problem is, if that object contains apostrophes, the Javascript above
parses incorrectly. For example, here is an output block:

var treeModel = {identifier: 'id',label: 'label',
items: [{id: 'app8',label: 'DAVE_TEST',description: 'dave's
test',loginURL: 'http://url1.com/login.html',logoutURL: 'http://
url2.com/login.html?logout=true'}]
};

Any suggestions on a clean way to escape the apostraphes above?

Thanks, - Dave
 

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top