Contains key Version 6 (Java)

Action group: JSON 


Description

The action checks if the JSON contains the key

Action icon


Settings of parameters

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
JSONJSON for processingRobin.JSON
Yes
KeyKey in the JSONRobin.String
Yes
Results
ResultLogical variable whose value is true if the key is contained in the JSON, otherwise false.Robin.Booleantrue

Special conditions of use

None.

Example of use

Task

Check if the JSON file test.json contains the key "firstname".

test.json
{
	"firstname":"Joe",
	"lastname": "Jackson",
	"gender":"male",
	"age": 28,
	"address": {
		"streetAddress": "101",
		"city": "San Diego",
		"state": "CA"
	},
	"phonenumber": [
	{ "type": "home", "number": "9349282382"}
	]
}

Solution

Use the "Open", "Contains key" actions. 

Implementation

  1. Assemble a robot scheme with the actions.
  2. Set the "Open" action parameters.
  3. Set the "Contains key" action parameters.
  4. Click "Start" in the top panel.

Result

The program robot completed successfully. JSON does contain the key.

  • Нет меток