Skip to content

Instantly share code, notes, and snippets.

@tristolliday
Created May 28, 2019 11:20
Show Gist options
  • Select an option

  • Save tristolliday/5b01e59d55db789915ebef1e88363064 to your computer and use it in GitHub Desktop.

Select an option

Save tristolliday/5b01e59d55db789915ebef1e88363064 to your computer and use it in GitHub Desktop.
Newtonsoft-Linq Structured Data(Json-LD) for FAQ Pages
<script type="application/ld+json">
@{
JObject structuredData =
new JObject(
new JProperty("@context", "https://schema.org"),
new JProperty("@type", "FAQPage"),
new JProperty("mainEntity",
new JArray(
from item in questions
select new JObject(
new JProperty("@type", "Question"),
new JProperty("name", (string)(item.GetProperty("question").Value().ToString())),
new JProperty("acceptedAnswer",
new JObject(
new JProperty("@type", "Answer"),
new JProperty("text", (string)(item.GetProperty("answer").Value().ToString()))
)
)
)
)
)
);
}
@Html.Raw(structuredData.ToString())
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment