Note that there are some explanatory texts on larger screens.

plurals
  1. POReplace double quotes in json string with empty string
    primarykey
    data
    text
    <p>I have problem with deserialization of json string, because string is bad format.</p> <p>For example json object consist string property statusMessage with value "Hello <strong>"dog"</strong> ".</p> <p>The correct format should be "Hello <strong>\" dog \"</strong> " .</p> <p>I would like remove double quotes from this property.</p> <p>Something Like this. "Hello <strong>"dog"</strong> ". -> "Hello dog ".</p> <p>Here is it original json string which I work.</p> <pre><code>"{\"jancl\":{\"idUser\":18438201,\"nick\":\"JANCl\",\"photo\":\"1\",\"sex\":1,\"photoAlbums\":1,\"videoAlbums\":0,\"sefNick\":\"jancl\",\"profilPercent\":75,\"emphasis\":false,\"age\":\"-\",\"isBlocked\":false,\"PHOTO\":{\"normal\":\"http://u.aimg.sk/fotky/1843/82/n_18438201.jpg?v=1\",\"medium\":\"http://u.aimg.sk/fotky/1843/82/m_18438201.jpg?v=1\",\"24x24\":\"http://u.aimg.sk/fotky/1843/82/s_18438201.jpg?v=1\"},\"PLUS\":{\"active\":false,\"activeTo\":\"0000-00-00\"},\"LOCATION\":{\"idRegion\":\"6\",\"regionName\":\"Trenčiansky kraj\",\"idCity\":\"138\",\"cityName\":\"Trenčianske Teplice\"},\"STATUS\":{\"isLoged\":true,\"isChating\":false,\"idChat\":0,\"roomName\":\"\",\"lastLogin\":1294925369},\"PROJECT_STATUS\":{\"photoAlbums\":1,\"photoAlbumsFavs\":0,\"videoAlbums\":0,\"videoAlbumsFavs\":0,\"videoAlbumsExts\":0,\"blogPosts\":0,\"emailNew\":0,\"postaNew\":0,\"clubInvitations\":0,\"dashboardItems\":1},\"STATUS_MESSAGE\":{\"statusMessage\":\"\"Status\"\",\"addTime\":\"1294872330\"},\"isFriend\":false,\"isIamFriend\":false}}" </code></pre> <p>Problem is here, json string consist this object:</p> <pre><code>"STATUS_MESSAGE": {"statusMessage":" "some "bad" value" ", "addTime" :"1294872330"} </code></pre> <p>Condition of string which I want modified:</p> <ul> <li>string start with <strong>"statusMessage":"</strong></li> <li>string can has any *<em>lenght from 0 -N *</em></li> <li>string end with <strong>", "addTime</strong></li> </ul> <p>So I try write pattern for string which start with "statusMessage":", has any lenght and is ended with ", "addTime.</p> <p>Here is it:</p> <pre><code> const string pattern = " \" statusMessage \" : \" .*? \",\"addTime\" "; var regex = new Regex(pattern, RegexOptions.IgnoreCase); //here i would replace " with empty string string result = regex.Replace(jsonString, match =&gt; ???); </code></pre> <p>But I think pattern is wrong, also I don’t know how replace double quotes with empty string (remove double quotes).</p> <p>My goal is :</p> <pre><code>"statusMessage":" "some "bad" value" </code></pre> <p>to <code>"statusMessage":" "some bad value"</code> </p> <p>Thank for advice</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload