Quotation marks coming out in the wrong JSON format!

0

I'm serializing a dictionary to JSON in Razor Pages, however the quotation marks (% with%), are leaving as "

_Layout.cshtml (UTF-8)

...
<body>
    ...
    <script type="application/ld+json">
        @JsonConvert.SerializeObject(new Dictionary<string, string>
        {
            { "@context", "http://schema.org" },
            { "@type", "Organization" },
            { "name", "Swenity" },
            { "url", "http://swenity.com" },
            { "logo", "/ui/lib/image/platform/swenity/basicPlatformWhite.png" }
        })
    </script>
    ...
</body>

Output:

{&quot;@context&quot;:&quot;http://schema.org&quot;,&quot;@type&quot;:&quot;Organization&quot;,&quot;name&quot;:&quot;HAHA&quot;,&quot;url&quot;:&quot;http://example.com&quot;,&quot;logo&quot;:&quot;http://example.com/image.png&quot;}

How can I make them come out in the correct format? As &quot;

    
asked by anonymous 10.01.2018 / 17:04

1 answer

0

I found the answer in an English SO question: link

Using @Html.Raw() I can get the output correctly without problems.

...
<body>
    ...
    <script type="application/ld+json">
        @Html.Raw(JsonConvert.SerializeObject(new Dictionary<string, string>
        {
            { "@context", "http://schema.org" },
            { "@type", "Organization" },
            { "name", "Swenity" },
            { "url", "http://swenity.com" },
            { "logo", "/ui/lib/image/platform/swenity/basicPlatformWhite.png" }
        }))
    </script>
    ...
    
14.01.2018 / 00:30