LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Build a Json with labview

Solved!
Go to solution

Hello

I need to create a json in the following structure:

 

{
    "Value1": {
        "Build": {
            "1": {
                "t_inst": {
                    "Type": "Gold",
                    "Key": "15",
                    "size": "big"
                },
                "1_avg": {
                    "Type": "Green",
                    "Key": "11",
                    "size": "big"
                },
                "2_avg": {
                    "Type": "Blue",
                    "Key": "21",
                    "size": "big"
                }
            }
        }
    },
    "Value2": {
        "Build": {
            "1": {
                "t_inst": {
                    "Type": "Grey",
                    "Key": "22",
                    "size": "small"
                },
                "1_avg": {
                    "Type": "Yellow",
                    "Key": "8",
                    "size": "big"
                },
                "2_avg": {
                    "Type": "Blue",
                    "Key": "21",
                    "size": "big"
                }
            }
        }
    }
}

How can i build it?

I've searched several forums, but none I've seen have as many layers as I need.

Could someone help me?

0 Kudos
Message 1 of 17
(426 Views)

Hello

I need to create a json in the following structure:

leandrofeder_0-1734539454560.png

 

I tried to put the json here, but it blocked my post

How can i build it?

I've searched several forums, but none I've seen have as many layers as I need.

Could someone help me?

0 Kudos
Message 2 of 17
(447 Views)

Hello

I need to create a json in the following structure:

 

leandrofeder_0-1734539564690.png

I tried to put the json here, but it blocked my post

I've searched several forums, but none I've seen have as many layers as I need.

Could someone help me?

0 Kudos
Message 3 of 17
(444 Views)

1. Install the JSONtext library. This is an amazing tool for creating and reading JSON files in LabVIEW.

2. Build up a cluster with the structure you want and then use the To JSON Text VI to create the text. You can then save that text string to a file.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 17
(415 Views)

Duplicated with Build json with this structure

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 5 of 17
(372 Views)

JSON Text is a toolkit I use for JSON work in LabVIEW

 

https://www.vipm.io/package/jdp_science_jsontext/

 

You start with modeling a cluster equivalent of JSON; then you can convert between cluster and JSON.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 6 of 17
(368 Views)

Guys, do you know how remove the duplicates of my JSON?

I have 2 equipments and my code create 6 items on JSON

Please, help me

 

{
  "EQ1":{
    "TCP":{
      "1":{
        "test_t_inst":{
          "Type":"ABC",
          "IP":"192.168.0.0",
          "Port":111,
          "Still":1,
          "Register":"Register",
          "Address":12345,
          "SizeLength":1,
          "FET":2,
          "Size":"big",
          "Conversion":"small"
        }
      }
    }
  },
  "EQ1":{
    "TCP":{
      "2":{
        "test_1_avg":{
          "Type":"ABC",
          "IP":"192.168.0.0",
          "Port":111,
          "Still":2,
          "Register":"Register",
          "Address":36871,
          "SizeLength":1,
          "FET":0,
          "Size":"big",
          "Conversion":"small"
        }
      }
    }
  },
  "EQ1":{
    "TCP":{
      "3":{
        "test_2_avg":{
          "Type":"ABC",
          "IP":"192.168.0.0",
          "Port":111,
          "Still":1,
          "Register":"Register",
          "Address":24572,
          "SizeLength":1,
          "FET":0,
          "Size":"big",
          "Conversion":"small"
        }
      }
    }
  },
  "EQ2":{
    "TCP":{
      "1":{
        "test_t_inst":{
          "Type":"ABC",
          "IP":"192.168.0.0",
          "Port":111,
          "Still":2,
          "Register":"Register",
          "Address":32451,
          "SizeLength":1,
          "FET":0,
          "Size":"big",
          "Conversion":"small"
        }
      }
    }
  },
  "EQ2":{
    "TCP":{
      "2":{
        "test_1_avg":{
          "Type":"ABC",
          "IP":"192.168.0.0",
          "Port":111,
          "Still":1,
          "Register":"Register",
          "Address":27789,
          "SizeLength":1,
          "FET":1,
          "Size":"big",
          "Conversion":"small"
        }
      }
    }
  },
  "EQ2":{
    "TCP":{
      "3":{
        "test_2_avg":{
          "Type":"ABC",
          "IP":"192.168.0.0",
          "Port":111,
          "Still":2,
          "Register":"Register",
          "Address":11234,
          "SizeLength":1,
          "FET":1,
          "Size":"big",
          "Conversion":"small"
        }
      }
    }
  },
  "user":"johnCena",
  "token":"327AD8E61A4F6EB329CE5190E",
  "password":"TheLastOfUS"
}

 

 

0 Kudos
Message 7 of 17
(318 Views)

Your 2D array constant on the BD has 6 rows.

I think you need to connect 'Array In' to the code instead of the constant.

0 Kudos
Message 8 of 17
(310 Views)

Yeap, but the constant it's only for test
The data entry it's coming on this format

0 Kudos
Message 9 of 17
(305 Views)

Sorry, I don't see your problem.

The constant has 6 rows resulting in 6 EQ entries in the JSON string.

If I cut the constant to 2 rows the resulting JSON string has 2 EQ entries.

0 Kudos
Message 10 of 17
(298 Views)