Jump to content

how do you extract JSON boolean value


Recommended Posts

Posted

Hi, I am using the JSON API to extract values from a string.

I got the extracted string value out [0] as expected but when I try to read out the Boolean value I got an error (Not a JSON Scalar: 'null' ).

/dahlin

getbool.png

Posted

I believe you want to wire the Get:Boolean to the output of the Get:from JSON rather than the Get:sub-Item with the way you have the name array wired.

The error is correct in that there is no Boolean in the JSON from the Get:sub-Item. A Boolean value in the JSON would be something like:

"MaximizeOnStart": false

I expect a value of [0] indicates a NULL rather than a logical 0.

Posted

Hi Tim,

I tried to change the file input to 'false' instead of '0' and rewire the other wire that you pointed out but it is still the same problem.

When probing the JSON wire it says it is a JSON Object.lvclass ?  instead of Scalar?

getbool2.png

Posted

I would expect the sub-Item to be a scalar and the input to the Get:Boolean to be a JSON object.

What does your JSON file look like? I would expect it to be something like below.

{
  "blemishResults": {
    "passfail": {
      "Blemishes_all_passed": false
    }
  }
}

JSON test.vi

  • Like 1
Posted

OK, when I compared to your JSON file I found the problem: I had written true or false with brackets like this [true] [false].

Thank you Tim!

/dahlin

Posted
4 hours ago, dahlin said:

OK, when I compared to your JSON file I found the problem: I had written true or false with brackets like this [true] [false].

In JSON, square brackets represent arrays. So, this is an array that contains one Boolean element:

[true]

 

This is an array containing three Boolean elements:

[true, false, true]

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.