My problem is that at the endpoint table in azure, the different titles and their corresponding values aren’t stored correctly. It is stored in a single string. Are there someone who has faced the same issue?
Don’t use string object, C-char array is much better- format using snprintf();
char dataStr(MAXDATA);
e.g. snprintf(dataStr, MAXDATA, “{[{“whatever0”:”%3.2f"},{“whatever1”:"%3.2f"}]}", val0, val1); OR better use the JsonParserGeneratorRK library.
Use a tool to check the JSON is correct. When you publish and follow in the Console that will only format the JSON payload if it is correct.
If you consider the 2 images I attached in the previous message, you might get an idea of what I’d like to do I publish an event where I have mad a string I argue that is in json format. But the Azure endpoint doesn’t divide the message as desired.
Okay, your first suggestion with the snprintf function looks like it would divide the data in the correct way. Have you tried this method before? I’ll check out the JsonparserGeneratorRK library to see if I can figure something out in 8 hours time It’s Bed time now where I am.
Yes, about 250,000 times a day. To help with the parsing of the JSON payload in the events by the web app event ingestion system, SQLserver I think, the format I use is paired {“N”:“var name”, “V”:“var_value”} to make this process as efficient as possible. How you structure the JSON, which must be correct, will depend upon what the web server does with it.
You need to escape the double quotes for the values just the same as you did for the keys.
I’d go with \"%.2f\".
Unless you have a fixed length format where you want all your decimal separators vertically alligned, then something like `%7.2f" (assuming 7 being the max length of the biggest number including potential negative sign) would be the way to go.
Alright, I’ve tried that, but my endpoint still receive all of it as a string ´. Is there a way to asure that it will be able to seperate the different variables?
The above image is what i receive in my endpoint table. As you can see it
is still received as a string. I read in another thread that particle.publish only
passes strings, so is the real issue? That the publish function is limited
compared to what I’d like it to do?
That is true, but JSON is typically serialised as JSON anyway so that is not the issue.
It's most likely the the format of the JSON and potentially also the setup of your webhook.
Can you also show the setup of your webhook?
BTW, have you seen this workshop
It also addresses Azure webhook setup.
Also, have you searched the forum for "azure json" and looked at the proposed solutions?
It's always good to have a thorough browse through the forum threads that touch on your issues at hand.
@ScruffR has covered your queries about the floating point number format? - I just quickly copied what I use - mea culpa - I actually don’t hand craft the JSON string, I define a number of const char arrays for sequences like variable name where they are used many times and insert them as a string using %s format control. Also, “%.2f” should be \"%.2f\". Please post how you get on with Azure IoT integration - we would all be interested if you can share your (eventual) success!
Actually, I've found an old topic from 2016, and currently await response from one of the dudes who answered it. I have half of the solution already and get my data divided in the query in Azure. However, one of the images showing what to write in the query to make ends meet, isn't there anymore. The topic I'm referering to is:
If I get an answer an it proves succesfull, I'll make a small document describing what I've done.
I've used "%.2" and removed the square brackets and one set of the curly brackets and this
works. However, I still get a whole string in Azure.
Alright, so the solution of passing the json string data, which can be made with a char is to alter the json data which is send from the particle console. In my case, the custom json file looks like this:
If anyone is interested in the string I send in the publish function, feel free to write a message to me