Extracting a JSON object from a serialized string in C# -
assuming have string looks ...
string s = "{ \"id\": \"1\", \"name\" : \"test\" } has other text in same string";
is there way, in c#, extract json part of text own "token" when splitting string apart?
the goal simple. in string contains text, , possibly json object, wanted try , separate text json pass 1 off appropriate facility. there no deserialization needed, there no validation needed, , there no need turn json text object. wanted able pull text out.
bellow code should looking (i tested it):
string s = "{ \"id\": \"1\", something:{xx:22, yyy: \"3\"}, \"name\" : \"test\" } has other text in same string"; var regexp = new regex("([{].+[}])"); var match = regexp.match(s);
Comments
Post a Comment