App for parsing VKontakte walls
GitHub ParserWallsVK

I can not understand why reader.Read() repeats itself seven times?

 JsonTextReader reader = new JsonTextReader(new StringReader(line)); reader.Read(); reader.Read(); if(reader.Value.ToString() == "error") { MessageBox.Show(" С данным идентификатором " + (groupRadioButton.Checked ? "группа" : "пользователь") + " не существует."); return 0; } reader.Read(); reader.Read(); reader.Read(); reader.Read(); reader.Read(); count = Convert.ToInt32(reader.Value); 

From here: Form1.cs

    1 answer 1

    The Read() method reads the next JSON token. Obviously, in this way the author skips unnecessary ones (having no meaning in the context of the current task).

    • 3
      ... and at the same time relies on their exact order, which is wrong and eliminates the positive effect of the use of the parser. - VladD
    • and where to read about it? and how it would be more correct to do? - pontekorvo
    • @pontekorvo What to read about? About Json.NET (on which the VK-parser relies) - it has quite good documentation . To understand how the library works, I advise you to try to compile it from source and podobezhit. Put a breakpoint somewhere and see which tokens are being skipped and why. - free_ze
    • @pontekorvo, the author of the VC parser, should rely on the names of the nodes in the JSON structure, and not blindly skip them, because, as correctly noted here, this logic will suffer from the rearrangement of data fields. But this remark makes sense only if the VC does not declare the exact composition and order of the data. - free_ze