LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

JSON Text Library from JDP Science

I am currently using LabVIEW 2021 64 bit and have installed the JSON text library from JKI Package manager to generate a JSON text output however the toolkit is not generating a valid format. For example the Make JSON Object.vi has 2 array inputs, one of names and one of JSON items. The names in the JSON Object indicator appear “Name" however the items are not surrounded by “" thus making it an invalid JSON type as checked by the following website:

 

https://jsonlint.com/

 

Attached is a picture of the front panel along with its inputs and outputs. The indicator shows the <JSON> Object indicator shows the text as {"Name":Value,"Name2":Value2}, however in order for this to be considered valid JSON all strings should be surrounded by " such as the following:

{"Name":"Value","Name2":"Value2"}

Phil_T_0-1645671236717.png

 

Any thoughts/comments are welcome.

 

0 Kudos
Message 1 of 3
(819 Views)

I think the JSON Items input of Make JSON Object.vi is expecting that the string values are already JSON formatted i.e. already have the quotation marks. There's another function called To JSON Text.vim which converts any input into appropriately formatted JSON text. The example below produces a correctly formatted JSON object.

MichaelBalzer_1-1645685486721.png

 

 

 




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 2 of 3
(787 Views)

Yes, any string input labeled "JSON" is expecting JSON.  Feeding in non-JSON strings will fail to get valid JSON output.

 

As an aside, always use the proper function to create your JSON; avoid the temptation to just throw quotes about your text, as that will fail in many edge cases 

0 Kudos
Message 3 of 3
(769 Views)