Skip to content

Conversation

@jcheng5
Copy link

@jcheng5 jcheng5 commented Jun 30, 2013

The current behavior for RJSONIO:

> cat(RJSONIO::toJSON(head(cars, 3)))
{
 "speed": [      4,      4,      7 ],
"dist": [      2,     10,      4 ] 
}
> cat(RJSONIO::toJSON(head(cars, 1)))
{
 "speed":      4,
"dist":      2 
}

When nrow(x) == 1, data frame variables are transmitted as scalars. This behavior makes sense for lists, but not for data frames, which are inherently tabular. The Shiny framework makes heavy use of RJSONIO and this behavior has surprised users several times.

With this patch:

> cat(RJSONIO::toJSON(head(cars, 1)))
{
 "speed": [      4 ],
"dist": [      2 ] 
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant