c# - Need help replacing parts of json string with regex -
how can replace following using regex.replace in c# application?
replace of following:
rendition\":{
with:
rendition\":[{
so adding left square bracket.
and also
replace:
\"}}
with:
\"}]}
i using jsonconvert newtonsoft convert xml json. rendition element in xmls may or may not array. trying force converted json array
replace:
(?<=rendition:)\"\{(.*?)\"\}\}
with:
\"[{$1\"}]}
in c#:
string json2 = regex.replace(json, "(?<=rendition\\\\\":)\\{(.*?)\\}\\}", "[{$1}]}");
see live demo of c# code running on ideone.
Comments
Post a Comment