Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to store array in capabilities.json object?

Hi, I want to store some values as an array in the capabilitis.json object, The initial value will be null, as based on user interaction I'm updating property value using persistProperties.  Curren...
  • dm-p's avatar
    4 years ago

    Hi Anonymous,

    There's no support for complex types as property values. Most developers will use text as the data type (as you're already doing), hide the property during enumeration and JSON.stringify the array before it's persisted. Use JSON.parse when you read it back.

    You may be better with the property default as "[]" so that an 'empty' property will parse to an empty array and be ready to work with in your code (or you could coalesce a default null property value to an empty array).

    Regards,

    Daniel