'R: create a signle json object with string keys
I am developing an API for an irrigation planning service, using plumber package, within a broader service ecosystem. To do so I have to follow an API specification document which asks me to return a single json object with string properties as a 200 response e.g.,
{ "field_urn": "urn:com.envrioLand.field_data:FDBE6F55-6179-4B88-9177-4AFBED33ADAC", "planning_days": 4, "notification_url": "https://consumer.com/advices/callback?secret=b7a3bc3f-c161-4e67-87e8-582a49e951b5" }
I have tried to organize my data in a data.frame, but the result was an array of json objects e.g.,
[ { "field_urn": "urn:com.envrioLand.field_data:FDBE6F55-6179-4B88-9177-4AFBED33ADAC", "planning_days": 4, "notification_url": "https://consumer.com/advices/callback?secret=b7a3bc3f-c161-4e67-87e8-582a49e951b5" } ]
On the other hand, when I organized my data in a list, I got a single json object, but the properties were arrays e.g.,
{ "field_urn": ["urn:com.envrioLand.field_data:FDBE6F55-6179-4B88-9177-4AFBED33ADAC"], "planning_days": [4], "notification_url": ["https://consumer.com/advices/callback?secret=b7a3bc3f-c161-4e67-87e8-582a49e951b5"] }
Both options are not acceptable according to the specification document.
So, do anyone knows if ther is a way to organize my data in order to get a single json object with string properties?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
