R programming language resources › Forums › Data manipulation › JSON array to dataframe
- This topic has 1 reply, 2 voices, and was last updated 13 years ago by
bryan.
- AuthorPosts
- April 7, 2012 at 9:26 pm #487
vmgmax
MemberHi,
I am somewhat new to R and trying to test out an API service. I have been able to pull the data from the service using Rcurl, the data returned is a JSON array structure. While I know there are two json packages, I can not seem to get the array into a dataframe without getting an error. Here is a sample of the data returned:
{ “1234”: { “id”: 1234, “ref_no”: “1234”, “external_account_id”: 1234, “store_id”: 0, “store_name”: “test”, “added_timestamp”: “2012-03-28T00:00:00”, “name”: “test”, “icon”: “http://test.png”, “active”: true, “hidden”: false, “sku”: “1234”, “in_apps”: [1234,1234,1234,1234], “product_type”: “app”, “addons”: [] },
{ “1234”: { “id”: 1234, “ref_no”: “1234”, “external_account_id”: 1234, “store_id”: 0, “store_name”: “test”, “added_timestamp”: “2012-03-28T00:00:00”, “name”: “test”, “icon”: “http://test.png”, “active”: true, “hidden”: false, “sku”: “1234”, “in_apps”: [], “product_type”: “app”, “addons”: [] }}Ideally, I would want all the labels “id”, to be column headers, one problem is occasionally there are mutliple values for some fields:
“in_apps”: [1234,1234,1234,1234]
“in_apps”: []Any thoughts or pointers would be greatly welcomed.
April 7, 2012 at 9:28 pm #489bryan
Participantvmgmax,
I don’t have a direct answer to your question, but this video talks indirectly about combining R and Javascript via JSON. It may give you some answers or ideas.
http://www.youtube.com/watch?v=7x0UdUghANI&hd=1
Bryan
- AuthorPosts
- You must be logged in to reply to this topic.