Convert string to JSON Object

前端 未结 7 1586
梦如初夏
梦如初夏 2020-12-09 01:57

How do I convert string to object? I am facing this problem because I am trying to read the elements in the JSON string using \"each\".

My string is given below.

7条回答
  •  庸人自扰
    2020-12-09 02:33

    Your string is not valid. Double quots cannot be inside double quotes. You should escape them:

    "{\"TeamList\" : [{\"teamid\" : \"1\",\"teamname\" : \"Barcelona\"}]}"
    

    or use single quotes and double quotes

    '{"TeamList" : [{"teamid" : "1","teamname" : "Barcelona"}]}'
    

提交回复
热议问题