User Manual
Print

Translating JsonValue to Boolean Array

Json Value as boolean array

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

This is used to convert the Json Value to Boolean array.

Parameters: Json Value

Output: Boolean Array

Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>jsonValue</variable><variable>boolArray</variable><variable>index</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\"><block type=\"typescript_expression\"><field name=\"EXPRESSION\">\"[true, false, false, true]\"</field></block></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=\"variables_set\"><field name=\"VAR\">boolArray</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Json_JsonValue_asBooleanArray\"><value name=\"jsonValue\"><block type=\"variables_get\"><field name=\"VAR\">jsonValue</field></block></value></block></value><next><block type=\"pxt_controls_for\"><value name=\"VAR\"><shadow type=\"variables_get_reporter\"><field name=\"VAR\">index</field></shadow></value><value name=\"TO\"><shadow type=\"math_whole_number\"><field name=\"NUM\">0</field></shadow><block type=\"math_arithmetic\"><field name=\"OP\">MINUS</field><value name=\"A\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"lists_length\"><value name=\"VALUE\"><block type=\"variables_get\"><field name=\"VAR\">boolArray</field></block></value></block></value><value name=\"B\"><shadow type=\"math_number\"><field name=\"NUM\">1</field></shadow></value></block></value><statement name=\"DO\"><block type=\"basic_consoleLogText\"><value name=\"text\"><block type=\"typescript_expression\"><field name=\"EXPRESSION\">boolArray[index].toString()</field></block></value></block></statement></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

The output:

JsonValue as Boolean Array - Output