07-13-2018 09:22 AM - edited 07-13-2018 09:27 AM
I'm parsing a json file several times using a sub VI and when I run it in highlight execution mode I see that the input string is different in the sub VI than what is being inputted into the other VI.
Here are the VIs:SubVI
VI
Attached is the json file that's being parsed.
Edit: An example of the parsing going wrong is that the McKenna_Desired_Phi is outputting zero as well as several of the other parsed values
07-13-2018 09:55 AM
I'm uncertain how JSON Parsing works. I've used an XML Parser that does "Search Parsing" -- you give it an XML String and "what you are looking for", it searches down the String until it finds the item, parses it, then gives you the rest of the String. If each element you are trying to extract occurs exactly once in the String, then you can make the parsing "order-independent" by simply parsing the entire String each time, but this will be much slower than parsing "Element 1", then "Element 2" (from "rest of string"), as each Search will immediately succeed and you'll march down the ever-decreasing "rest of String" until you are done.
Does JSON work similarly? Are elements of the Tree unique? Are they "removed" after the Parse? Do you always search from the entire Tree? Is the Parse order-dependent?
From your description, I'm guessing the answer to the critical last question above is "Yes", and explains the issues you are seeing.
Bob Schor
07-13-2018 10:04 AM
So you're saying that I should parse them in the order that they are in the JSON file? i.e. Pressure -> Pressure_Reference->McKenna_Desired_Velocity-> etc. ?
Like this:
07-13-2018 10:06 AM
Well, that would be the first thing I would try ...
Bob Schor
07-13-2018 10:29 AM - edited 07-13-2018 10:32 AM
This is still giving me 0 for the desired_phi, but now I am getting a "Param not found" error
Edit: Never mind the error was because my JSON wasn't being read, but the reading of zero is still there
07-13-2018 10:59 AM
Time to hang up your Engineer hat and put on your Scientist hat.
Do some Experiments.
Bob Schor
07-13-2018 11:22 AM
Do you have a link to the json toolkit you are using?
07-13-2018 01:44 PM
I figured it out, I needed to use "Fract/Exp String To Number" to parse out the double values