I'm having trouble sending properly formatted json string containing multiple lines inside a var, in a HTTP POST. The responses from the server have no trouble encoding newlines as '\n', and that shows up in resulting var...no matter what way I try to sneak them in (multiple escapes, etc) the server returns an 'improperly formatted' error.
What gives? How can I encode newlines inside a json string? Any help greatly appreciated.
To be clear, an example would be:
(note the newlines in "text")
What gives? How can I encode newlines inside a json string? Any help greatly appreciated.
To be clear, an example would be:
JSON:
{
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
"object": "text_completion",
"created": 1589478378,
"model": "text-davinci-002",
"choices": [
{
"text": "\n\nThis is a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 6,
"total_tokens": 11
}
}
(note the newlines in "text")