Thank you for supporting the Cloud Customer Connect Community in 2024. It's a gift to work with you!

Look back
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

Retrieving size of JSON key using groovy script in EPBCS

Summary:

Need to retrieve size of keys in JSON array using EPBCS groovy script.

Content (required):

Hello guys,

I have the following JSON array:

def json_str = """{

  "1010CC":

   {

   "user1": "abc@xyz.net",

   "user2": "abc@xyz.net""

   }

  ,

  "1020CC": 

  {

   "user1": "abc@xyz.net",

   "user2": "abc@xyz.net",

"user3": "abc@xyz.net"

  }

  ,

  "2010CC": 

  {

   "user1": "abc@xyz.net",

   "user2": "abc@xyz.net"

  } """

I need to get the size of the keys like for 1010CC-> size = 2, for 1020CC->size=3,etc.

I have tried the below.

Version (include the version you are using, if applicable):


Code Snippet (add any code snippets that support your topic, if applicable):

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!