Exploring dictionary types : Name-Value Pairs

zajadiya
Giga Contributor

Hi,

I have created a field named "Current Versions" in the cmdb_software_product_model table.

I added the following data to this field:

{
  "abc": "test",
  "bcd": "tst"
}

After saving the record, I tried to retrieve it using the Table API via a curl command.

However, the value of the "Current Versions" field is returned as a JSON string, like this:

"{\"abc\":\"test\",\"bcd\":\"tst\"}"

I have set the field type as Name-Value Pairs, but the API is still returning it as an escaped string instead of a JSON object.

Is this the expected behavior, or am I doing something wrong?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@zajadiya 

that's how data is stored in Name-value pair field type i.e. JSON string

That's OOTB behavior.

good explanation here

Exploring dictionary types : Name-Value Pairs 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@zajadiya 

that's how data is stored in Name-value pair field type i.e. JSON string

That's OOTB behavior.

good explanation here

Exploring dictionary types : Name-Value Pairs 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

zajadiya
Giga Contributor

Is this behaviour documented anywhere?