I get a line from the server like:

[1510,[0,0,0,0,0,0,0],0,[{\"195562162_456239289\":[\"HammAli & Navai Им грош цена\",\"https:\\/\\/m.vk.com\\/mp3\\/audio_api_unavailable.mp3...\",\"HammAli & Navai\",\"Им грош цена\",\"\",false],\"195562162_456239288\":[\"Градусы & Кравц Выходи за меня\",\"https:\\/\\/m.vk.com\\/mp3\\/audio_api_unavailable.mp3...\",\"Градусы & Кравц\",\"Выходи за меня\",\"\",false]},[\"\"],\"\"]] 

If I get such a string, then everything works fine. I regularly get what is between {and} because if you parse this line right away, an exception is thrown that an array cannot be parsed, an object is needed But you get an incident if there is a quote in any line (For example, there is one quote in the line \"Им грош \" цена\" ). Then an Invalid property identifier character... is thrown Invalid property identifier character... How to solve it?

  • And why do you use regulars, you do not know about the existence of JSON parsers? - VladD
  • I use JObject.Parse(); but I say, if you try to immediately parse the resulting line, it does not work (Exeption: "Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path", line 1, position 1. "). Therefore, I specifically highlight what I need. - Max
  • I have only a couple of questions that you generally want to achieve in your application, because, as I understand it, you can read the music from Vkontakte, but they already closed the API a long time ago and you can see it perfectly in your JSON . Based on this other question, where did you get this terrible JSON ? - EvgeniyZ
  • I know how to decipher the link, so don't worry. Received through POST request for m.vk.com/audios+id with parameters _ajax = 1 and offset = 0 - Max
  • Well, use JArray , since this is an array. - Alexander Petrov

1 answer 1

Use JArray instead of JObject since you have an array and not an object.

 var str = "[1510,[0,0,0,0,0,0,0],0,[{\"195562162_456239289\":[\"HammAli & Navai Им грош цена\",\"https:\\/\\/m.vk.com\\/mp3\\/audio_api_unavailable.mp3...\",\"HammAli & Navai\",\"Им грош цена\",\"\",false],\"195562162_456239288\":[\"Градусы & Кравц Выходи за меня\",\"https:\\/\\/m.vk.com\\/mp3\\/audio_api_unavailable.mp3...\",\"Градусы & Кравц\",\"Выходи за меня\",\"\",false]},[\"\"],\"\"]]"; var array = JArray.Parse(str);