c# - Extract json data from string using regex -


i have data string below:

.... data=[{"caseno":1863,"casenumber":"rd14051315","imageformat":"jpeg","shiftid":241,"city":"riyadh","imagetypeid":2,"userid":20}] --5qf7xjyp8snivhqycpkmdjs-zg0qde4oqiyig content-disposition: form-data ..... 

i want fetch json data above string. how can use regex find part of string? tried finding indexof("data=[") , indexof("}]") not working fine , proper way do.

i'm not entirely there isn't better way this, following regex string should data need:

// define regular expression, including "data=" // put latter part (the part want) in own group regex regex = new regex(     @"data=(\[{.*}\])",     regexoptions.multiline );  // run regular expression on input string match match = regex.match(input);  // now, if we've got match, grab first group if (match.success) {     // our json string     string jsonstring = match.groups[1].value;      // whatever need (e.g. de-serialise json)     ...      } } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -