Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to serialize/de-serialize a String array.

    Looking for a tip here. I want to take the list of selected String values from a SelectItem where multiple="true" and store them in a cookie. Then retrieve them from the cookie and restore the selection later.

    I have the selected values as a String array. How can I serialize that to store as a String in the cookie and then deserialize back to an array?

    #2
    Figured it out. channelCodes is my String array.

    This encodes it to a String.

    String savedChannels = JSON.encode(JSOHelper.arrayConvert(channelCodes));

    This decodes the String back into a String array.

    JavaScriptObject jso = JSON.decode(savedChannels);
    String[] restoredChannels = JSOHelper.convertToJavaStringArray(jso);

    Comment

    Working...
    X