User Manual
Print

Checking JsonValue is True or False

Json Value as Boolean

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>jsonValue</variable><variable>stringArray</variable><variable>index</variable></variables><block type=\"Json_JsonValue_asBoolean\" disabled=\"true\" x=\"-22\" y=\"428\"><value name=\"jsonValue\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">jsonValue</field></block></value></block></xml>"}
				
			

This is used to check Json Value is true or false.

Parameters: Json Value

Output: Boolean (True/False)

Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>jsonValue</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">jsonValue</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Json_parse\"><value name=\"str\"><shadow type=\"text\"><field name=\"TEXT\">true</field></shadow></value></block></value><next><block type=\"basic_consoleLogText\"><value name=\"text\"><block type=\"Json_JsonValue_stringify\"><value name=\"jsonValue\"><block type=\"variables_get\"><field name=\"VAR\">jsonValue</field></block></value></block></value><next><block type=\"controls_if\"><mutation else=\"1\"/><value name=\"IF0\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow><block type=\"Json_JsonValue_asBoolean\"><value name=\"jsonValue\"><block type=\"variables_get\"><field name=\"VAR\">jsonValue</field></block></value></block></value><statement name=\"DO0\"><block type=\"basic_consoleLogText\"><value name=\"text\"><block type=\"typescript_expression\"><field name=\"EXPRESSION\">\"This is TRUE.\"</field></block></value></block></statement><statement name=\"ELSE\"><block type=\"basic_consoleLogText\"><value name=\"text\"><block type=\"typescript_expression\"><field name=\"EXPRESSION\">\"This is FALSE.\"</field></block></value></block></statement></block></next></block></next></block></statement></block></xml>"}
				
			

The output:

JsonValue as Boolean - Output