Alternate rbv_api.stringToJson()? - Forum - Rollbase - Progress Community

Alternate rbv_api.stringToJson()?

 Forum

Alternate rbv_api.stringToJson()?

This question is answered

I used rbv_api.stringToJson() to convert String from rbv_api.sendHttpGet() to JSON array of object in EVAL, And got one problem.

When String is too long, I got "Formula too long: 275865 chars, 102400 allowed (line #262) in formula".

 

I have changed MaxFormulaSize in shared.properties to increased allowed chars in formula, And it work.

But my data still growth and it will error again.

 

So, Is there other javascript function to convert string to JSON with no limit of character?

 

thank.

Kasipat

Verified Answer
  • Hi Kasipat,

    Yes if you return value is an object which needs conversion to String then you can use JSON.stringify ,whereas if your return value is a string and want to convert into JSON object then as you said JSON.parse can be used.

    Regards,

    Shiva

All Replies
  • Hi Kasipat,

    Could you try below one?

    JSON.stringify(eval("(" + str + ")"));

    Here "str" is the string which is returned from rbv_api.sendHttpGet() API.

    Regards,

    Shiva

  • Hi Shiva,

     

    I tried JSON.stringify(eval("(" + str + ")")); , It didn't work.

    But I found JSON.parse(str); that is invert of JSON.stringify and used it.

    And it work like rbv_api.stringToJson() with no char limit.

     

    Thanks,

    Kasipat

  • Hi Kasipat,

    Yes if you return value is an object which needs conversion to String then you can use JSON.stringify ,whereas if your return value is a string and want to convert into JSON object then as you said JSON.parse can be used.

    Regards,

    Shiva