In the code below, when "data" is printed with:
Display_printf(display, 0, 0, "score received: %.*s\n", ret, data);
the json data is printed correctly:
{"zip":97306,"score":130}
However, when I do this:
Display_printf(display, 0, 0, "score received: %s\n", data);
the json data contains extra characters (sometimes weird/unknown chars) like this:
{"zip":97306,"score":130}R
Why does the second print method show extra characters wheras the first one doesn't? How can I fix it so that the second print method works? What is the equivalent code for doing "%.*s", so that data can store the correct json data?
do
{
ret = HTTPClient_readResponseBody(httpClientHandle, data, sizeof(data),
&moreDataFlag);
if(ret < 0)
{
printError("httpTask: response body processing failed", ret);
}
Display_printf(display, 0, 0, "%.*s \r\n",ret,data);
len += ret;
}
while(moreDataFlag);