Search code examples
jsonobjectibm-cloudwatson-conversation

Why IBM Watson Assistant Complex object properties do not update?


According to the documentation "If the context variable is a complex type such as JSON object, a JSON merge procedure is used to update the variable. The merge operation adds any newly defined properties and overwrites any existing properties of the object." . but when I try that it does not work.

Code in a node:

    "context": {
         "comp_obj": "{a:1,b:2}" 
  }

Code in the very next node:

    "context": {
        "comp_obj": "{a:3}"
  }

But when I check values with Manage Context it shows $comp_obj = "{a:3}" and not "{a:3, b:2}" , So do I miss something?


Solution

  • The issue is that you have defined your value as a string not a JSON object.

    Change: "{a:1,b:2}" to: {"a":1, "b":2} and it should work fine.