How to screen double quotes

92 views
Skip to first unread message

yur15t

unread,
Mar 19, 2012, 2:31:49 PM3/19/12
to cytoscapeweb-discuss
I'm trying to use quoted text in one of node's attributes:

var network_json = {
dataSchema: {
nodes: [ { name: "label", type: "string" },
{ name: "foo", type: "string" }
]
},
data: {
nodes: [ { id: "1", label: "1", foo: "Text without quotes" },
{ id: "2", label: "2", foo: "Some \"quoted\" text" }
]
}
};
vis.draw({network: network_json});

And then making listeners for each node:

vis.addListener("click", "nodes", function(event) {
alert(event.target);
})

But I've got "Unexpected token ILLEGAL" error while clicking on a node
with quoted text. How should I screen quotes there?

Christian Lopes

unread,
Mar 19, 2012, 5:30:35 PM3/19/12
to cytoscapew...@googlegroups.com
Why don't you try single-quoted strings?
Example:

foo: 'Some "quoted" text'

Some JSON parsers seem to have issues with special characters. We've added some workarounds to CW in order to avoid those issues, but sometimes it seems that a new browser version comes up with another parser problem.

Can you please tell us what browser/version you are using?

Thanks,
Christian

yur15t

unread,
Mar 20, 2012, 3:52:31 AM3/20/12
to cytoscapeweb-discuss
Hi, Christian, thanks for your response.

That was just an example of where i'm using quoted strings. Actually i
receive JSON object via jQuery.getJSON() from PHP-script. It contains
list of names and descriptions as strings. Both can contain single or
double quotes.

$.getJSON(scriptURL+'?t=q&q='+escape(q), function(data){
var nodes_arr = new Array();
var edges_arr = new Array();

for (var i=0;i<data.length;i++)
{
nodes_arr[nodes_arr.length] = {id: data[i].name,
label: data[i].name,
abstract: data[i].abstract,
};
}

drawNodes(nodes_arr);
})

Here is a JSON-string from PHP-script:
[{"name":"some name","abstract":"some text"},{"name":"some other
name","abstract":"some \"quoted\" text"}]

And here is how i draw nodes:

function drawNodes(n_arr)
{
var net = {
dataSchema: {
nodes: [
{name: "label", type: "string" },
{name: "abstract", type: "string" },
]
},
data:{
nodes:n_arr,
}
};

vis.draw({network: net});
vis.ready(function() {
vis.addListener("click", "nodes", function(event)
{
alert(event.target);
}
});
}

I even tried data[i].abstract.split('\"').join('"'), didn't help.

This bug appears in every browser i tried: Chrome 18.0; Firefox 11.0,
Opera 11.61, IE 8.0

Christian Lopes

unread,
Mar 20, 2012, 1:07:21 PM3/20/12
to cytoscapew...@googlegroups.com
I've created a bug report for it (http://cbio.mskcc.org/cytoscape/bugs/view.php?id=2690) and have already found a solution, but need to run more tests before releasing the fixed version.

Thanks for the feedback!

Christian
Message has been deleted
Message has been deleted

yur15t

unread,
Mar 20, 2012, 5:03:09 PM3/20/12
to cytoscapeweb-discuss
Thanks for bugreporting that!
.split('\"').join('\\"') doesn't help either though.

Christian Lopes

unread,
Mar 20, 2012, 5:15:34 PM3/20/12
to cytoscapew...@googlegroups.com
It has to be fixed in the Flash code.

Christian

On Tue, Mar 20, 2012 at 4:54 PM, yur15t <ezhko...@gmail.com> wrote:
Thanks for bugreporting that!
.split("\").join("\\") doesn't help either though.

On Mar 20, 9:07 pm, Christian Lopes <chrtan...@gmail.com> wrote:

Ekansh Gupta

unread,
Jan 11, 2013, 12:40:40 AM1/11/13
to cytoscapew...@googlegroups.com
Hey Christian,

I facing issues/errors while using double quotes or single quotes in attribute values string,
with Vis.networkModel().data.nodes.length

So the bug stated above was fixed?

Thanks
Ekansh

Christian Lopes

unread,
Jan 17, 2013, 12:01:54 PM1/17/13
to cytoscapew...@googlegroups.com
Hi Ekansh

It should have been fixed a long time ago. Are you using the latest version of C.Web (1.0.2)?
If so, can you tell me the versions of your OS, browser and Flash player, since I can't reproduce it? If possible, please also send a sample of your original network data (json, xgmml, etc).


Thanks,
Christian
Reply all
Reply to author
Forward
0 new messages