Reg JSON Object

Hi All,

Thanks in advance for the Help.

I am trying to store the a Json String ex: "{"a":null,"b":2}" into a column in MySQL of type JSON.

but when i call a rule which returns the json string and pass it to the write to data store entity , it is failing to store JSON string saying "invalid JSON text"as the 

input is getting changed to [a:,b:2] without the quotes. 

Could you please suggest how to preserve the quotes in transfer and storing the value?

appreciate your help.

Thanks
Raj 

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    I'm not sure if this will help, but it might be worth mentioning how to pass a json string when you're testing expressions, as you need to escape the quotation marks rather carefully.

    So, for example, to produce a JSON string of {"a":null,"b":2} then you would need to use "{""a"":null,""b"":2}" within an expression. Note that the quotes within the JSON string have been entered twice - this can be tricky to do as the designer auto-adds multiple quotes when doing this, so be very careful when entering the values.

    An alternative to the above is to convert to JSON from a dictionary, which can be easier than messing around with quotes. In your example, the following would get the JSON string that you require:

    a!toJson(
      {
        a: null,
        b: 2
      }
    )

    The above applies to other, but not all areas of Appian; for example in the integration designer you need to escape the JSON string in this way, but not in the Value field of an expression rule input. You do, however, need to escape in this way in the Expression field for an expression rule input.

  • Hi Philb,
    Now another issue :-(,
    a rule which returns a type of text ex: "[{"a":1,"b":null},{"a":5,"b":7 ]"
    (sample , but actual string is very big json object/file loaded in KC ). I am not able to convert it to Dictionary object to use it with toJson function .
    Tried to cast,split etc . but not working as expected .
    Any suggestion will be helpful. Thanks for your time
    Raj
Reply
  • Hi Philb,
    Now another issue :-(,
    a rule which returns a type of text ex: "[{"a":1,"b":null},{"a":5,"b":7 ]"
    (sample , but actual string is very big json object/file loaded in KC ). I am not able to convert it to Dictionary object to use it with toJson function .
    Tried to cast,split etc . but not working as expected .
    Any suggestion will be helpful. Thanks for your time
    Raj
Children
No Data