David B
David B

Reputation: 29968

Reading JSON arrays from R

Then I read JSON files from R using rjson it seems that JSON arrays (enclosed with []) are converted to (unnamed) R lists, not vectors.

Therefore I have to first unlist(recuresice=F) each of those lists before I can work with them.

  1. Is there any logic behind this conversion I am missing? I mean, why use a list (and not a vector) to store an array?
  2. Is there any way to control this behavior of rjson (or perhaps another recommended JSON parser for R)?

Upvotes: 1

Views: 1424

Answers (1)

mbq
mbq

Reputation: 18628

JSON arrays can store values of different types, so they are equivalent to R unnamed lists.

Upvotes: 2

Related Questions