none
string to json converison RRS feed

  • Question

  • hii
     
    how can we convert a string with comma seperated values to json using jquery
     
    Eg
     
    input is like below
     
    'sss', 'ttt', 'lll'
     
    Regards
    Kunjammu
    Friday, August 10, 2012 11:18 AM

Answers

  • Kunjammu,

    The string format you gave could not be convert to json object directly. If you managed to split them, you can convert it to a json array object:

    var jsonObj = '{"stringarray" : [ {"value" : "sss"},  {"value" : "ttt"}, {"value" : "lll"} ]}'; 
    var obj = $.parseJSON(jsonObj); 

    Hope this helps,

    thanks.


    Forrest Guo | MSDN Community Support | Feedback to manager

    Monday, August 13, 2012 3:07 AM
    Moderator