I want to parse the html in which the JSON resides, then to write it to the database.
this is what html looks like
<div class="bContentColumn"> <script type="text/javascript"> Core.Namespace.exp('Pages.Detail.modelData', {"employees":[ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ]}); Core.Namespace.exp('Pages.Detail.useFakeSaleBlock', false); </script> </div> The amount of data in Json may be different. I get to the div very simply
string div_inner_text = htmlDocument.DocumentNode.SelectSingleNode("//div[@class='bContentColumn']").InnerText; Then I start cutting the line, by the first comma, which occurs in the line
string result = div_inner_text.Substring(div_inner_text.IndexOf(',') + 1); I got the start, but here's how do I get the JSON ending? Probyval so
string res_two = result.Substring(0, result.IndexOf(';')); But I do not like this option, because the binding to the semicolon is not reliable and can generally occur in the text. Well, the question is, how can I get the most beautiful out of diva Json?