LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read and configure json file

Solved!
Go to solution

Hello,
I'm coming to you because I'm a bit stuck.
I want to read a json file and configure it.
I have 4 controls (passenger 1 to 4). The controls are true or false when doing the import picture to clipboard.
So I have my controls configured if the value is 0 (in the config file) the control (passenger) appears and if it's 1 the control is not possible.

I did it with an .ini file but I am asked to do it with a .json file.
I don't know json at all, I tried this but it doesn't work.
I don't know how to do the property node (visible, value) in this case with the keys and values.
Can you help me please?
Or give me some hints?
The json file does not supported here, so i enclose its screen capture
Thank you very much 

Download All
0 Kudos
Message 1 of 5
(3,382 Views)
Solution
Accepted by topic author Ngouda

It's good that you already have the JSONtext library. Just wire all controls to a cluster and input it into the 'To JSON text.vim". You'll get the correct JSON string.

JSON example.png

0 Kudos
Message 2 of 5
(3,374 Views)

Hello Basjong53,

Thank you for your reply.
Can you save your example under the precious version please? I have Labview 2021 and where to send me the vi directly if you don't mind.
Thanks Ngouda_0-1662969969853.png

 

0 Kudos
Message 3 of 5
(3,315 Views)

@Ngouda wrote:

Hello Basjong53,

Thank you for your reply.
Can you save your example under the precious version please? I have Labview 2021 and where to send me the vi directly if you don't mind.
Thanks 

 


That image is a snippet, so after saving it you can drop it in your diagram.

0 Kudos
Message 4 of 5
(3,297 Views)

Hi ngouda,

 

please don't send PMs when you already received good answers!

 


@Ngouda wrote:

I did it with an .ini file but I am asked to do it with a .json file.
I don't know json at all, I tried this but it doesn't work.


What's wrong with the example snippet you got?

 


@Ngouda wrote:

I don't know how to do the property node (visible, value) in this case with the keys and values.


Use the label of those controls as key, then you can easily look up the corresponding control reference based on the keys loaded from JSON. Then just use a "visible" property node with the reference found for each key…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(3,268 Views)