I realize you have already solved your issue but I wanted to point something out to you. In the C language a single string can span multiple line. You have to start and end each substring with a quote and there can be no commas between substrings. In your case you have this monstrosity of a string :
"{\"state"\:{\"reported"\:{\"co2"\:\" %d "\, \"temperature"\:\" %f "\, \"humidity"\:\" %f" \, \"pressure"\ :\" %f "\, \"battery"\ :\" %d" \, \"name"\ :\" co2-sensor" \, \"timestamp"\ : \" %d" \, \"ttl"\: \" %d " \ }}}"
If I were you, I would split it into substrings with each label and value on a line. This would make it much easier to see the cause of the problem you had. Here is a start for the first few items :
"{"
"\"state"\:"
"{"
"\"reported"\:"
"{"
"\"co2"\:\" %d "
"\, \"temperature"\:\" %f "
"}"
"}"
"}"
and so on... This is all one string and the newline characters are not included in it. I am not sure I did that correctly because commas and colons do not need to be escaped with backslash, only quotes and other special characters do. When each item is separated I think it is much easier to see the problems.