How Can I use key value pair in system property?

amiie
Kilo Contributor

Hi want to define key and value pair(Dictionary)in system property and call the system property in the script. Depending on the key I provided in the script the property should return the value.

Any help will be appreciated.

Regards,

Amitra 

3 REPLIES 3

johnstettin
Tera Expert

Amitra,

A system property is essentially a key value pair itself, can you explain your use case a bit better? I suppose if you only wanted a single system property to reference and then hold multiple sub-key/value pairs you could store a JSON object as a string and reference its key/values as needed.

 

I know json is a way.. But I am not willing to implement JSON. Can you please tell me what is the functionality of choice field in property?

Javier Arroyo
Kilo Guru

as an example of what @johnstettin mention.

Value of sys_property

{
  "keyName1": "String Value",
  "keyName2": 0,
  "keyName3": ["string1", "string2", ...],
  "keyName4:" {
     "innerKeyName1": "Inner Key Value",
     "innerKeyName2": 4
  }
}

 

and use it as such

var config = global.JSON.parse(propertyName);
gs.log(config.keyName1); //String value