The problem is when I use fromJSON, toJSON functions the output is not the same as the initial JSON. txt_field becomes an array "txt_field": ["bar"].
I'm not good at R but I think this about data types in R. Even the a string is 1 length vector with type character. So, I would like to know the reason behind this and more importantly how do I read the json and pass it to an API without changing the original structure.
jsonlite will assume that you dont want to unbox single entry fields,
if you wanted single entries to be unboxed you can use auto_unbox=TRUE param on your toJSON() call.
However, this will unbox list_field 'foo' also...
Thank you. I read that in the documentation too, but as you said it will unbox the other list. So, you are saying there is no way to preserve the actual format?