1

I'm trying to create a JSON file using Lists in R. Here's what I'm trying to do:

toJSON(list(j$key=projIssues)) #I get error that I can't do this    

print(j$key)#---displays ACME

Here's how I created the above in a static manner, but would like to do it dynamically.

projIssues = list(
    issueName = i$name,
    total=y$total
    )

toJSON(list(key=projIssues))

The above returns:

{
   "ACME": {
            "issueName": "Wish",
            "total":      6 
   } 
}

1 Answer 1

3

I am not sure if I understand your question. If what you want is to change the key, you can use the names function.

J = list(list(a=1,b=2))
names(J) = "ACME"
cat(toJSON(J))
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Randy for the solution

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.