LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
AudioVideoDisco

Retain all errors option of Merge Errors.vi does not output a valid JSON string

Status: New

Current Behavior:

When using the "retain all errors" option of the Merge Errors function the combined error message JSON output is not a valid JSON string.

This is the source output of Merge Errors when retain all errors is active - it is not a valid JSON string.

 

<JSONErrorMultiple_1.0>[{
    "status": true,
    "code": 111,
    "source": "This is a test message including\nnewlines"
},{
    "status": true,
    "code": 222,
    "source": "This is a test message including\nnewlines"
}]

 

 

Desired Behavior:

Make the combined errors source string a valid JSON string so that it can be parsed by other tools.

Valid JSON string:

 

[{"status":true,"code":111,"source":"This is a test message including\nnewlines"},{"status":true,"code":222,"source":"This is a test message including\nnewlines"}]

 

 The above JSON string can be formatted nicely by most tools - e.g. JSON pretty print - https://jsonformatter.org/json-pretty-print

 

The below string including the JSONErrorMultiple_1.0 key (but formatted correctly) also works:

 

{"<JSONErrorMultiple_1.0>":[{"status": true,"code": 111,"source": "This is a test message including\nnewlines"},{"status": true,"code": 222,"source": "This is a test message including\nnewlines"}]}

 

 

8 Comments
AudioVideoDisco
Member

The following VI snippet VI illustrates the issue.

In short, it would be great if the JSON-like output from Merge Errors.vi was valid JSON format.

retain_all_errors_JSON.png

fefepeto_kb
Member

I agree that this issue is really strange and shall be fixed.

FYI: the snippets don't work in the idea exchange, as in the forum. Could you please upload you code as a file attachment instead?

joerg.hampel
Active Participant

The snippet works for me if I download it from the detail view.




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )


wiebe@CARYA
Knight of NI

Also note the stupid distinction between

JSONErrorMultiple_1.0

and

JSONErrorSingle_1.0

The first is for 1..n errors, the second, completely redundant, is for 1 error. 

 

Look into the multiple error VIs to see exactly how much CPU and code is wasted on this 'feature'.

AudioVideoDisco
Member

@fefepeto_kb I tried to post the actual VI but it won't let me post it on this board for some reason.

 

AudioVideoDisco_0-1701282661555.png

 

wiebe@CARYA
Knight of NI

>@fefepeto_kb I tried to post the actual VI but it won't let me post it on this board for some reason.

 

Attachments aren't allowed on the idea exchange comments...

fefepeto_kb
Member

Hey! Thanks for trying. I also checked the snippet and it worked with the method joerg.hampel suggested.

It seems we have two issues with the forum itself in this post :D. One is that the snippets don't work with resized images, which I think it should, because it is much easier. The other is that VIs cannot be posted in comments. I think it would be useful to share workaround codes here as well.

wiebe@CARYA
Knight of NI

>One is that the snippets don't work with resized images, which I think it should, because it is much easier.

 

That is a well known issue. It has been like this for years. I assume there are good reasons (bandwidth) to shrink the images and remove meta data like snippets. It might be bad for us, but (marginal)  better for the environment.