06-07-2022 07:26 AM - edited 06-07-2022 07:28 AM
Hello!
I recently ran into a strange behavior with a LabVIEW Web Service VI. I Have a simple VI (GET method) that is returning an array of data. Sometimes this array can be empty (which is totally fine) but when using the "Output Type -> Terminal -> JSON" the response the web service is sending to my browser is not empty at all.
Here is a very simple example:
When using the flatten to JSON function the resulting JSON string does exactly look like I would expect LV doing it with the "auto JSON" function for the indicator terminal.
But the response to the web request does look like this:
For each request there is different random data for the "Numeric" and "Double" objects. This behavior is very confusing. If the array is empty then the JSON response should look like the one in the first picture ("JSON string").
Am I doing something wrong or is this just a bug?
06-07-2022 12:12 PM
Since none of us have a magic 8-ball that tells us what's happening in your code we're left to guess. How have you confirmed that the array is indeed empty? Have you been able to reproduce this with simulated data? If not why do you think that is?
06-08-2022 01:26 AM - edited 06-08-2022 01:39 AM
There is no code .. just what you see in the pictures, an empty array wired to an indicator that is connected to the web VIs connector pane. The flatten to JSON is just to show the expected result. How can I confirm it is empty? The flatten to JSON does show it, the indicator too and a probe when debugging it as well - so yes it is 100% empty.
The moment you fill in some data into the array everything is fine.
I attached an example project just start the web service and call the test method from a Browser of your choice. You always get an array with 1 element (so not empty) always with an empty string but sometimes with random data for the decimal and double values (just refresh the website over and over and you will see).