1

I was trying to parse several JSONs on a dataframe on R, and I failed miserably.

The files were quite different. Some were quite simple and easy to parse (with library jsonlite), other were heavily nested and I got into much trouble to parse them. I eventually did it (very badly) but it was pain in the ass. And if I use another JSON with different nesting... It doesn't work anymore.

I googled quite a lot and I couldn't find any nice tool for that. There was tidyjson but it's not available anymore. On python with pandas it is simpler but I would like to stay with R.

Question: is there any library that you know of to do this? Or can you recommend an external tool to pre-process the JSONs and then load the result in R?

Thanks in advance! Cheers.

Example JSON

1 Answer 1

1

Much delayed, but tidyjson is available again. Apologies for the trouble :) As the maintainer, I am pretty biased in my use of tidyjson, but it is my favorite tool for the job.

The tidyr and purrr packages have recently gained some helpful verbs for nested lists as well with pluck, unnest, flatten, pivot_longer, pivot_wider, and friends.

There is a whole article on the topic here:

https://tidyr.tidyverse.org/articles/nest.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.