Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:35:45+00:00 2026-06-11T11:35:45+00:00

I suspect I’m missing something obvious here, but how do I parse deeply nested

  • 0

I suspect I’m missing something obvious here, but how do I parse deeply nested structures in R using RJSONIO?

For example – suppose I directly want to reference $familyName in results.data.json$MRData$RaceTable$Races[[1]]$Results[[8]]$Driver as grabbed using the following snippet:

require(RJSONIO)
resultsURL='http://ergast.com/api/f1/2012/1/results.json'
results.data.json=fromJSON(resultsURL)

RJSONIO doesn’t appear to want to parse the ..$Results[[i]] data as structured elements?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:35:46+00:00Added an answer on June 11, 2026 at 11:35 am
    require(RJSONIO)
    
    somedata1<-list(a=1,b='w')
    fromJSON(toJSON(somedata1))
    # $a
    # [1] 1
    
    # $b
    # [1] "w"
    
    somedata2<-list(a=1,b=2)
    fromJSON(toJSON(somedata2))
    # a b 
    # 1 2 
    
    somedata3<-list(a='v',b='w')
    fromJSON(toJSON(somedata3))
    #  a   b 
    # "v" "w" 
    
    fromJSON(toJSON(somedata3),simplify=StrictNumeric)
    # $a
    # [1] "v"
    
    # $b
    # [1] "w"
    
    fromJSON(toJSON(somedata2),simplify=FALSE)
    # $a
    # [1] 1
    
    # $b
    # [1] 2
    
    fromJSON(toJSON(somedata3),simplifyWithNames = FALSE)
    # $a
    # [1] "v"
    
    # $b
    # [1] "w"
    
    
    fromJSON(toJSON(somedata2),simplifyWithNames = FALSE)
    # $a
    # [1] 1
    
    # $b
    # [1] 2
    

    from the examples above by default RJSON simplifies “collections/arrays of homogeneous scalar elements to R vectors”. This simplification can be controlled using simplify or simplifyWithNames. In your example you can do any of the following to access the element you want:

    require(RJSONIO)
    resultsURL='http://ergast.com/api/f1/2012/1/results.json'
    results.data.json=fromJSON(resultsURL)
    results.data.json$MRData$RaceTable$Races[[1]]$Results[[8]]$Driver['familyName']
    # familyName 
    #    "Pérez" 
    
    results.data.json=fromJSON(resultsURL,simplify=FALSE)
    results.data.json$MRData$RaceTable$Races[[1]]$Results[[8]]$Driver$familyName
    # [1] "Pérez"
    
    results.data.json=fromJSON(resultsURL,simplify=StrictNumeric)
    results.data.json$MRData$RaceTable$Races[[1]]$Results[[8]]$Driver$familyName
    # [1] "Pérez"
    
    results.data.json=fromJSON(resultsURL,simplifyWithNames = FALSE)
    results.data.json$MRData$RaceTable$Races[[1]]$Results[[8]]$Driver$familyName
    # [1] "Pérez"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I suspect that I am missing something very obvious here but this doesn't work:
I suspect I just being very dumb with this and missing something obvious. But
I suspect I am doing something dumb here but I am getting seg faults
I suspect I am missing something basic but vital but because of it my
I suspect I must be missing something very elementary but I can't seem to
I strongly suspect I shouldn't be using a static factory method here, but for
I suspect I am going to feel really stupid after posting this but here
I suspect the answer is no, but is it possible to do something like
Suspect I am doing something stupid, but I can't see for the wood for
I suspect the solution here is probably really simple, but I'm stumped... // Create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.