I have tried several technics to push json object into an array and to save in the same format of the below example, but without success.
Is anyone has a solution to do it in R ?
Thanks you
EDIT :
I found the solution.
library(jsonlite)
#Set an empty list
list1 <- vector(mode = 'list', length = 2)
# data example
json_data <- list(object1 = list(birthday = '2000-02-14', Age = '20'),
object2 = list(Candidate_Number = '1999283', first_attempt = TRUE),
object3 = list(name = 'John E.', result = list(), study_hours = 150, GPA = 3.8, exam_infos = list(cost = 800, location = 'F3C6V9', past_exams = list(list(exam_name = 'Science', score = 'passed'), list(exam_name = 'Geometric', score = 'passed')))),
object4 = list(study_manual_used = 'Physics Theory', version_found = list(Digital = '1999-01-01', Paper = '1999-01-01')))
# append data into json
for(i in length(list1)){
list1[[i]] <- json_data
}
# Write to json on his home
write(toJSON(list1, auto_unbox = TRUE, pretty = TRUE), file.path(Sys.getenv()['USERPROFILE'], 'file.json'))