I'm facing a problem trying to convert a tibble to a JSON. It should be pretty straightforward, but looks like it's not.
This is what I've done and achieved so far:
# Original tibble
original_tibble <- tibble::tibble(
matter = c("「Organization Module - Organization of the address book panel",
"「Member」 module - set the department"),
`Problem description` = c("It is essentially the same as the above requirements",
"After selecting a person, you can adjust multiple departments to which he belongs\nAfter selecting a department, you can also add members to the current department"),
classification = c("Product demand", "product demand"),
`review date` = c("2019-10-30T00:00:00.000Z", "2019-10-29T16:00:00.000Z")
)
# Nested tibble
nested <- original_tibble |>
rowwise() |>
nest(fields = everything())
# Convert to JSON
toJSON(list(records = nested), pretty = T)
But this is what I'm getting:
{
"records": [
{
"fields": [
{
"matter": "「Organization Module - Organization of the address book panel",
"Problem description": "It is essentially the same as the above requirements",
"classification": "Product demand",
"review date": "2019-10-30T00:00:00.000Z"
},
{
"matter": "「Member」 module - set the department",
"Problem description": "After selecting a person, you can adjust multiple departments to which he belongs\nAfter selecting a department, you can also add members to the current department",
"classification": "product demand",
"review date": "2019-10-29T16:00:00.000Z"
}
]
}
]
}
And this is what I need:
{
"records": [
{
"fields": {
"matter": "「Organization Module - Organization of the address book panel",
"problem description": "It is essentially the same as the above requirements",
"classification": "Product demand",
"Review date": "2019-10-30T00:00:00.000Z"
}
},
{
"fields": {
"matter": "「Member」 module - set the department",
"Problem description": "After selecting a person, you can adjust multiple departments to which he belongs\nAfter selecting a department, you can also add members to the current department",
"classification": "product demand",
"review date": "2019-10-29T16:00:00.000Z"
}
}
],
"fieldKey": "name"
}
Slightly but dramatically —for the purpose— different.
You can try this:
Created on 2024-01-22 with reprex v2.1.0.9000