02-23-2022 09:02 PM
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:
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"}
Any thoughts/comments are welcome.
02-24-2022 12:52 AM
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.
02-24-2022 04:06 AM
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