ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

YAML Parser

I just got a YAML file I have to parse. Before I "roll my own" Does anyone have a parser?

0 Kudos
Message 1 of 6
(4,719 Views)

JSON may be a valid YAML parsing thingamjijjy. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 6
(4,683 Views)

Can you explain? YAML looks nothing like JSON. How might I use a JSON parser to read in a YAML doc?

0 Kudos
Message 3 of 6
(4,672 Views)

@nanocyte wrote:

Can you explain? YAML looks nothing like JSON. How might I use a JSON parser to read in a YAML doc?


How do they look?  Does it effect how you show them or what the data is?

 

We cannot tell unless you show a data file or attempt to use one in LabVIEW code you show.  So, you want "Specific "answers?  Geneneral information won't work. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 6
(4,670 Views)

Googling "LabVIEW YAML" resulted in this being the first link - https://www.vipm.io/package/nicolas_bats_lib_yaml_parser/

 

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
0 Kudos
Message 5 of 6
(4,666 Views)

How do they look? 

Using examples from wikipedia. YAML looks like this:

--- # Sequencer protocols for Laser eye surgery
- step:  &id001                  # defines anchor label &id001
    instrument:      Lasik 2000
    pulseEnergy:     5.4
    pulseDuration:   12
    repetition:      1000
    spotSize:        1mm

- step: &id002
    instrument:      Lasik 2000
    pulseEnergy:     5.0
    pulseDuration:   10
    repetition:      500
    spotSize:        2mm
- step: *id001                   # refers to the first step (with anchor &id001)
- step: *id002                   # refers to the second step
- step: *id002

And JSON looks like this

{
  "firstName": "John",
  "lastName": "Smith",
  "isAlive": true,
  "age": 27,
  "address": {
    "streetAddress": "21 2nd Street",
    "city": "New York",
    "state": "NY",
    "postalCode": "10021-3100"
  },
  "phoneNumbers": [
    {
      "type": "home",
      "number": "212 555-1234"
    },
    {
      "type": "office",
      "number": "646 555-4567"
    }
  ],
  "children": [
      "Catherine",
      "Thomas",
      "Trevor"
  ],
  "spouse": null
}

Note all the curly brackets in the JSON and the dashes in the YAML

 


Does it effect how you show them or what the data is?

I don't understand this question. I'm not trying to "show them" I'm just trying to get values from a string. For the example above, I might want to output an array of a cluster of "pulseEnergy" (a dbl) and "pulseDuration" (an int). I think this is what people commonly mean when they try to parse a file.

 

0 Kudos
Message 6 of 6
(4,656 Views)