This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

How to Send a Response as JSON Format From LabVIEW Web Service

Updated Oct 12, 2023

Reported In

Software

  • LabVIEW

Issue Details

I want to create a method VI in my LabVIEW Web Service that sends out a response as JSON format.
I know how to configure the terminal output of a method VI to send a response as JSON format, but I do not want to use terminal to send out a response.
How can I send a response as JSON format from my method VI without using its terminal?
 

Solution

You can use combination of Set HTTP Header.vi, Flatten To JSON.vi, and Write Response.vi .
To send a response as JSON format, set "Content-Type" header to use "application/json" using Set HTTP Header.vi.
Flatten To JSON.vi will convert your data into a UTF-8 JSON string, which you can input into Write Response.vi as a body of the response.