Serializing and unserializing an array in javascript

后端 未结 3 1857
无人共我
无人共我 2021-02-02 09:13

I\'m using the tag-it library for jquery to make a tagging system (a bit like the stackoverflow one).

After the user types his tags the library returns a javascript arra

3条回答
  •  攒了一身酷
    2021-02-02 10:03

    How about just JSONing it?

    var arr = [1,2,3];
    var arrSerialized = JSON.stringify(arr);
    ...
    
    var arrExtracted = JSON.parse(arrSerialized);
    

    By the way, JSON is often used for serializing in some other languages, even though they have their own serializing functions. )

提交回复
热议问题