alexcb / rjson

20 stars 12 forks source link

Square brackets (toJSON) #5

Closed caitiecollins closed 10 years ago

caitiecollins commented 10 years ago

Hello,

I have been using your R package rjson. It has been really useful for some of my current work, in particular for enabling the creation and integration of dynamic network graphs into a user interface generated with R package Shiny.

Everything was working smoothly until sometime this week when I updated a number of R packages as well as my version of R. Now the same code that previously worked fine to generate the contents of the file "Good.html" (shown below in the FIRST screenshot) has for some reason started generating instead the contents of the SECOND file below, "Problematic.html"... good problematic

You can see that while "Good.html" contains the appropriate (square) brackets in the section containing the bulk of the script, a la:

var g = { "nodes":[{.....}], "edges":[{....}]};

by contrast, "Problematic.html" is overrun with square brackets. I can use some regular expressions to convert Problematic back into Good, but I was hoping to ask your opinion first in case there was some (new?) argument in toJSON that I should be using to convert a list (in my case a list of two lists, the first of length 20_6 for "nodes" and the second of length 19_6 for "edges") to JSON format s.t. its bracketing format resembles the Good version and not the Problematic version.

Finally, if nothing has changed in rjson's toJSON function, might you still have any suggestions for me? I would really appreciate it. I'm keen to have something stable so I can release this stuff as part of a package whose development I'm trying to wrap up. I'd be really grateful for your help, but either way I just wanted to say thanks for all the great work you've been doing on rjson; it's been very useful and quite nice to work with so far.

Thanks for your time and input, and let me know if anything I said was unclear or if you have any questions.

All the best, Cait.

alexcb commented 10 years ago

The only recent change was the handling of escaping control characters: https://github.com/alexcb/rjson/commit/c3f36509712878733e95c75c23a4b5e93b8651d9

It sounds like your input data once was a character vector of length 1 (a string), and now it's a list() with a string in it. You'll need to look at your input data. If the input data hasn't changed, then I can take a look provided you give me a (small) sample which I can use to reproduce the problem.

If you come up with a recursive convert single item lists back to vectors, we could include it as a helper function. (and vice-versa promote vectors to lists to ensure that single length vectors get output as lists)

Thanks, Alex

alexcb commented 10 years ago

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004")))
{"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004")))
{"a":"hello\u0004"}
caitiecollins commented 10 years ago

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil notifications@github.com wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62001759.

alexcb commented 10 years ago

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins notifications@github.com wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62001759.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62004626.

caitiecollins commented 10 years ago

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil notifications@github.com wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins notifications@github.com wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62001759.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62004626.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62014961.

alexcb commented 10 years ago

Thanks for the sample code. I trimmed down the number of loops for the dummy data.

I don't see any problems on my end:

{"nodes":[{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6},{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6}],"edges":[{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12}]}

Perhaps you could try working the reproduction case down to the smallest amount of input data, and include the buggy serialized json as well.

Cheers

On Thu, Nov 6, 2014 at 11:19 AM, caitiecollins notifications@github.com wrote:

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil < notifications@github.com> wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins notifications@github.com

wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62001759.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62004626.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62014961.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62034938.

caitiecollins commented 10 years ago

Hi,

Yeah, the dummy data was not designed to be particularly nice, I just copied the format I was using to generate my real data. But at least now we know that your results don't look like mine!

Mine still look like this: toJSON(out.nodes) [{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]}]

While I hate to say something that will probably make me sound uninformed if not genuinely stupid, what exactly do you mean by "buggy serialized json"? If it's possible, for clarity's sake, could you provide me with a line or two or code that I could use to debug this problem in a way that would be useful to you and/or me?

Thanks, Caitlin.

On Thu, Nov 6, 2014 at 7:57 PM, Alex Couture-Beil notifications@github.com wrote:

Thanks for the sample code. I trimmed down the number of loops for the dummy data.

I don't see any problems on my end:

{"nodes":[{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6},{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6}],"edges":[{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12}]}

Perhaps you could try working the reproduction case down to the smallest amount of input data, and include the buggy serialized json as well.

Cheers

On Thu, Nov 6, 2014 at 11:19 AM, caitiecollins notifications@github.com wrote:

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil < notifications@github.com> wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins < notifications@github.com>

wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62001759.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62004626.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62014961.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62034938.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62041038.

alexcb commented 10 years ago

Serialized json is what toJSON returns. toJSON is a serializer which takes data from R and serializes it to json format. http://en.wikipedia.org/wiki/Serialization

When reporting (and debugging) a bug, it's best to get the smallest possible reproduction case -- the smaller the input data, the easier it is to see what's going wrong.

for example, take the following line (it's a single line of code I can copy and paste, it's clear to understand what's going on -- no loops or external data to load in)

noquote(toJSON(list(list(id=1, x=5), list(id=10, x=2))))

It gives me

[{"id":1,"x":5},{"id":10,"x":2}]

What does it give you?

On Fri, Nov 7, 2014 at 5:35 AM, caitiecollins notifications@github.com wrote:

Hi,

Yeah, the dummy data was not designed to be particularly nice, I just copied the format I was using to generate my real data. But at least now we know that your results don't look like mine!

Mine still look like this: toJSON(out.nodes) [{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]}]

While I hate to say something that will probably make me sound uninformed if not genuinely stupid, what exactly do you mean by "buggy serialized json"? If it's possible, for clarity's sake, could you provide me with a line or two or code that I could use to debug this problem in a way that would be useful to you and/or me?

Thanks, Caitlin.

On Thu, Nov 6, 2014 at 7:57 PM, Alex Couture-Beil < notifications@github.com> wrote:

Thanks for the sample code. I trimmed down the number of loops for the dummy data.

I don't see any problems on my end:

{"nodes":[{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6},{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6}],"edges":[{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12}]}

Perhaps you could try working the reproduction case down to the smallest amount of input data, and include the buggy serialized json as well.

Cheers

On Thu, Nov 6, 2014 at 11:19 AM, caitiecollins notifications@github.com

wrote:

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil < notifications@github.com> wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins < notifications@github.com>

wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62001759.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62004626.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62014961.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62034938.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62041038.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62143440.

caitiecollins commented 10 years ago

Hi,

Sorry, I was misinterpreting "buggy serialized json", reading it more as "buggy-serialized" json, which was a concept I didn't understand, rather than just the adjective "buggy" and "serialized json" as the subject. Anyway, on to the more interesting topic of conversation, I get a different result from you when I run that line of code!

Mine looks like this:

[{"id":[1],"x":[5]},{"id":[10],"x":[2]}]

Any thoughts on why that might be?

Thanks, Caitlin.

On Fri, Nov 7, 2014 at 4:01 PM, Alex Couture-Beil notifications@github.com wrote:

Serialized json is what toJSON returns. toJSON is a serializer which takes data from R and serializes it to json format. http://en.wikipedia.org/wiki/Serialization

When reporting (and debugging) a bug, it's best to get the smallest possible reproduction case -- the smaller the input data, the easier it is to see what's going wrong.

for example, take the following line (it's a single line of code I can copy and paste, it's clear to understand what's going on -- no loops or external data to load in)

noquote(toJSON(list(list(id=1, x=5), list(id=10, x=2))))

It gives me

[{"id":1,"x":5},{"id":10,"x":2}]

What does it give you?

On Fri, Nov 7, 2014 at 5:35 AM, caitiecollins notifications@github.com wrote:

Hi,

Yeah, the dummy data was not designed to be particularly nice, I just copied the format I was using to generate my real data. But at least now we know that your results don't look like mine!

Mine still look like this: toJSON(out.nodes)

[{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]}]

While I hate to say something that will probably make me sound uninformed if not genuinely stupid, what exactly do you mean by "buggy serialized json"? If it's possible, for clarity's sake, could you provide me with a line or two or code that I could use to debug this problem in a way that would be useful to you and/or me?

Thanks, Caitlin.

On Thu, Nov 6, 2014 at 7:57 PM, Alex Couture-Beil < notifications@github.com> wrote:

Thanks for the sample code. I trimmed down the number of loops for the dummy data.

I don't see any problems on my end:

{"nodes":[{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6},{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6}],"edges":[{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12}]}

Perhaps you could try working the reproduction case down to the smallest amount of input data, and include the buggy serialized json as well.

Cheers

On Thu, Nov 6, 2014 at 11:19 AM, caitiecollins < notifications@github.com>

wrote:

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil < notifications@github.com> wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins < notifications@github.com>

wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62001759>.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62004626.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62014961.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62034938.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62041038.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62143440.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62166235.

alexcb commented 10 years ago

Excellent -- we made some progress :)

What version of rjson, R and Operating System are you using?

Can you send me the output of:

library(rjson); sessionInfo();

Thanks, Alex

On Fri, Nov 7, 2014 at 8:11 AM, caitiecollins notifications@github.com wrote:

Hi,

Sorry, I was misinterpreting "buggy serialized json", reading it more as "buggy-serialized" json, which was a concept I didn't understand, rather than just the adjective "buggy" and "serialized json" as the subject. Anyway, on to the more interesting topic of conversation, I get a different result from you when I run that line of code!

Mine looks like this:

[{"id":[1],"x":[5]},{"id":[10],"x":[2]}]

Any thoughts on why that might be?

Thanks, Caitlin.

On Fri, Nov 7, 2014 at 4:01 PM, Alex Couture-Beil < notifications@github.com> wrote:

Serialized json is what toJSON returns. toJSON is a serializer which takes data from R and serializes it to json format. http://en.wikipedia.org/wiki/Serialization

When reporting (and debugging) a bug, it's best to get the smallest possible reproduction case -- the smaller the input data, the easier it is to see what's going wrong.

for example, take the following line (it's a single line of code I can copy and paste, it's clear to understand what's going on -- no loops or external data to load in)

noquote(toJSON(list(list(id=1, x=5), list(id=10, x=2))))

It gives me

[{"id":1,"x":5},{"id":10,"x":2}]

What does it give you?

On Fri, Nov 7, 2014 at 5:35 AM, caitiecollins notifications@github.com

wrote:

Hi,

Yeah, the dummy data was not designed to be particularly nice, I just copied the format I was using to generate my real data. But at least now we know that your results don't look like mine!

Mine still look like this: toJSON(out.nodes)

[{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]}]

While I hate to say something that will probably make me sound uninformed if not genuinely stupid, what exactly do you mean by "buggy serialized json"? If it's possible, for clarity's sake, could you provide me with a line or two or code that I could use to debug this problem in a way that would be useful to you and/or me?

Thanks, Caitlin.

On Thu, Nov 6, 2014 at 7:57 PM, Alex Couture-Beil < notifications@github.com> wrote:

Thanks for the sample code. I trimmed down the number of loops for the dummy data.

I don't see any problems on my end:

{"nodes":[{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6},{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6}],"edges":[{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12}]}

Perhaps you could try working the reproduction case down to the smallest amount of input data, and include the buggy serialized json as well.

Cheers

On Thu, Nov 6, 2014 at 11:19 AM, caitiecollins < notifications@github.com>

wrote:

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil < notifications@github.com> wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins < notifications@github.com>

wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62001759>.

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62004626>.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62014961.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62034938.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62041038.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62143440.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62166235.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62167759.

caitiecollins commented 10 years ago

Oh good grief, I figured out what was going wrong. Turns out "nothing" is the answer, with respect to your package. One of the other packages I have been loading to run in conjunction with yours has apparently updated itself to have as a dependency a package called "jsonlite". You'll never guess what one of its functions is called... Looks like after all I can solve this problem with a double colon. Sorry if I wasted your time. You were very helpful, and it's been nice talking to you. Thank you.

I wish you all the best, Caitlin.

On Fri, Nov 7, 2014 at 5:36 PM, Alex Couture-Beil notifications@github.com wrote:

Excellent -- we made some progress :)

What version of rjson, R and Operating System are you using?

Can you send me the output of:

library(rjson); sessionInfo();

Thanks, Alex

On Fri, Nov 7, 2014 at 8:11 AM, caitiecollins notifications@github.com wrote:

Hi,

Sorry, I was misinterpreting "buggy serialized json", reading it more as "buggy-serialized" json, which was a concept I didn't understand, rather than just the adjective "buggy" and "serialized json" as the subject. Anyway, on to the more interesting topic of conversation, I get a different result from you when I run that line of code!

Mine looks like this:

[{"id":[1],"x":[5]},{"id":[10],"x":[2]}]

Any thoughts on why that might be?

Thanks, Caitlin.

On Fri, Nov 7, 2014 at 4:01 PM, Alex Couture-Beil < notifications@github.com> wrote:

Serialized json is what toJSON returns. toJSON is a serializer which takes data from R and serializes it to json format. http://en.wikipedia.org/wiki/Serialization

When reporting (and debugging) a bug, it's best to get the smallest possible reproduction case -- the smaller the input data, the easier it is to see what's going wrong.

for example, take the following line (it's a single line of code I can copy and paste, it's clear to understand what's going on -- no loops or external data to load in)

noquote(toJSON(list(list(id=1, x=5), list(id=10, x=2))))

It gives me

[{"id":1,"x":5},{"id":10,"x":2}]

What does it give you?

On Fri, Nov 7, 2014 at 5:35 AM, caitiecollins < notifications@github.com>

wrote:

Hi,

Yeah, the dummy data was not designed to be particularly nice, I just copied the format I was using to generate my real data. But at least now we know that your results don't look like mine!

Mine still look like this: toJSON(out.nodes)

[{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]}]

While I hate to say something that will probably make me sound uninformed if not genuinely stupid, what exactly do you mean by "buggy serialized json"? If it's possible, for clarity's sake, could you provide me with a line or two or code that I could use to debug this problem in a way that would be useful to you and/or me?

Thanks, Caitlin.

On Thu, Nov 6, 2014 at 7:57 PM, Alex Couture-Beil < notifications@github.com> wrote:

Thanks for the sample code. I trimmed down the number of loops for the dummy data.

I don't see any problems on my end:

{"nodes":[{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6},{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6}],"edges":[{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12}]}

Perhaps you could try working the reproduction case down to the smallest amount of input data, and include the buggy serialized json as well.

Cheers

On Thu, Nov 6, 2014 at 11:19 AM, caitiecollins < notifications@github.com>

wrote:

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil < notifications@github.com> wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins < notifications@github.com>

wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62001759>.

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62004626>.

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62014961>.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62034938.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62041038.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62143440.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62166235.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62167759.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62182585.

alexcb commented 10 years ago

Glad it all worked out.

On Fri, Nov 7, 2014 at 9:55 AM, caitiecollins notifications@github.com wrote:

Oh good grief, I figured out what was going wrong. Turns out "nothing" is the answer, with respect to your package. One of the other packages I have been loading to run in conjunction with yours has apparently updated itself to have as a dependency a package called "jsonlite". You'll never guess what one of its functions is called... Looks like after all I can solve this problem with a double colon. Sorry if I wasted your time. You were very helpful, and it's been nice talking to you. Thank you.

I wish you all the best, Caitlin.

On Fri, Nov 7, 2014 at 5:36 PM, Alex Couture-Beil < notifications@github.com> wrote:

Excellent -- we made some progress :)

What version of rjson, R and Operating System are you using?

Can you send me the output of:

library(rjson); sessionInfo();

Thanks, Alex

On Fri, Nov 7, 2014 at 8:11 AM, caitiecollins notifications@github.com

wrote:

Hi,

Sorry, I was misinterpreting "buggy serialized json", reading it more as "buggy-serialized" json, which was a concept I didn't understand, rather than just the adjective "buggy" and "serialized json" as the subject. Anyway, on to the more interesting topic of conversation, I get a different result from you when I run that line of code!

Mine looks like this:

[{"id":[1],"x":[5]},{"id":[10],"x":[2]}]

Any thoughts on why that might be?

Thanks, Caitlin.

On Fri, Nov 7, 2014 at 4:01 PM, Alex Couture-Beil < notifications@github.com> wrote:

Serialized json is what toJSON returns. toJSON is a serializer which takes data from R and serializes it to json format. http://en.wikipedia.org/wiki/Serialization

When reporting (and debugging) a bug, it's best to get the smallest possible reproduction case -- the smaller the input data, the easier it is to see what's going wrong.

for example, take the following line (it's a single line of code I can copy and paste, it's clear to understand what's going on -- no loops or external data to load in)

noquote(toJSON(list(list(id=1, x=5), list(id=10, x=2))))

It gives me

[{"id":1,"x":5},{"id":10,"x":2}]

What does it give you?

On Fri, Nov 7, 2014 at 5:35 AM, caitiecollins < notifications@github.com>

wrote:

Hi,

Yeah, the dummy data was not designed to be particularly nice, I just copied the format I was using to generate my real data. But at least now we know that your results don't look like mine!

Mine still look like this: toJSON(out.nodes)

[{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]},{"id":[1],"label":[2],"x":[3],"y":[4],"size":[5],"color":[6]}]

While I hate to say something that will probably make me sound uninformed if not genuinely stupid, what exactly do you mean by "buggy serialized json"? If it's possible, for clarity's sake, could you provide me with a line or two or code that I could use to debug this problem in a way that would be useful to you and/or me?

Thanks, Caitlin.

On Thu, Nov 6, 2014 at 7:57 PM, Alex Couture-Beil < notifications@github.com> wrote:

Thanks for the sample code. I trimmed down the number of loops for the dummy data.

I don't see any problems on my end:

{"nodes":[{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6},{"id":1,"label":2,"x":3,"y":4,"size":5,"color":6}],"edges":[{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12},{"id":7,"source":8,"target":9,"color":10,"type":11,"size":12}]}

Perhaps you could try working the reproduction case down to the smallest amount of input data, and include the buggy serialized json as well.

Cheers

On Thu, Nov 6, 2014 at 11:19 AM, caitiecollins < notifications@github.com>

wrote:

Hi,

Sure, here is some dummy code to get the list type I have and the bracketing problem I get when I run toJSON:

node <- list(1,2,3,4,5,6) names(node) <- c("id", "label", "x", "y", "size", "color")

edge <- list(7,8,9,10,11,12) names(edge) <- c("id", "source", "target", "color", "type", "size")

out.nodes <- list() for(i in 1:20){ out.nodes[[i]] <- node }

out.edges <- list() for(i in 1:19){ out.edges[[i]] <- edge }

out <- list(nodes= out.nodes, edges= out.edges)

out.JSON <- noquote(toJSON(out))

out.JSON

Can you copy and paste that and see if you get the same abundance of square brackets as I do in the resulting "out.JSON" object?

Thanks very much.

Cheers, Caitlin.

On Thu, Nov 6, 2014 at 5:14 PM, Alex Couture-Beil < notifications@github.com> wrote:

Would you be able to produce an example that I can just copy and paste into R without having to load any external files please.

On Thu, Nov 6, 2014 at 8:20 AM, caitiecollins < notifications@github.com>

wrote:

Hey,

Thanks for getting back to me so quickly!

If you have a second, can you take a look at these objects? They were the ones partaking in the current problem. The main file of interest is "out.Rdata", which when I use in the line:

noquote(toJSON(out))

generates the object in JSON format with the problematic square brackets.

The other files I'm including are "out.nodes.Rdata" and "out.edges.Rdata", which are the two components of the object "out", which was created like so:

out <- list(nodes = out.nodes, edges = out.edges)

And then finally just for your reference, I've included "out.JSON.Rdata" which contains the problematic output of the noquote(toJSON(out)) command.

Please let me know if you can reproduce the problem, and then what your thoughts on it are.

Thanks again, Caitlin.

On Thu, Nov 6, 2014 at 4:04 PM, Alex Couture-Beil < notifications@github.com> wrote:

This doesn't show any of the behaviour described:

cat(toJSON(list(a="hello\u0004"))) {"a":"hello\u0004"}

cat(toJSON(c(a="hello\u0004"))) {"a":"hello\u0004"}

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62001759>.

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62004626>.

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62014961>.

— Reply to this email directly or view it on GitHub < https://github.com/alexcb/rjson/issues/5#issuecomment-62034938>.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62041038.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62143440.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62166235.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62167759.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62182585.

— Reply to this email directly or view it on GitHub https://github.com/alexcb/rjson/issues/5#issuecomment-62185338.