User Manual
Print

Showing Keys in String Array Format

Convert the content of string to JsonValue

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>jsonValue</variable><variable>getKeys</variable></variables><block type=\"Json_JsonValue_getKeys\" disabled=\"true\" x=\"23\" y=\"517\"><value name=\"jsonValue\"><block type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">jsonValue</field></block></value></block></xml>"}
				
			

This is used to get keys of the Json Value to string array.

Parameters: Json Value (Object Operation)

Output: String Array

Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>jsonValue</variable><variable>getKeys</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\">{\"name\":\"Hello World\", \"Number\":255}</field></shadow></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">getKeys</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Json_JsonValue_getKeys\"><value name=\"jsonValue\"><block type=\"variables_get\"><field name=\"VAR\">jsonValue</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=\"basic_consoleLogText\"><value name=\"text\"><block type=\"text_join\"><mutation items=\"2\"/><value name=\"ADD0\"><shadow type=\"text\"><field name=\"TEXT\">The keys are: </field></shadow></value><value name=\"ADD1\"><shadow type=\"text\"><field name=\"TEXT\"/></shadow><block type=\"variables_get\"><field name=\"VAR\">getKeys</field></block></value></block></value></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

The output:

Convert the Content of String to JsonValue - Output