title: Can I use variables in JSON-LD?
body: <p>I'm trying to implement Schema.org in a FAQ page, but it seems repetitive to re-write all the questions and answers in the schema.</p>
  
  <p>So I was wondering if I could call a variable or a class in my JSON-LD to retrieve the questions and answers from the body.</p>
  
  <p>Something like the code below:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;head&gt;
  &lt;script type="application/ld+json"&gt;
      {
        "@context": "https://schema.org",
        "@type": "FAQPage",
        "url": "https://www.example.com",
        "mainEntity": [{
          "@type": "Question",
          "name": {{question}},
          "acceptedAnswer": {
            "@type": "Answer",
            "text": {{answer}}
          }
        }]
        }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h3 class="question"&gt;This is question number one?&lt;/h3&gt;
      &lt;p id="answer"&gt; This is the answer to Q1.&lt;/p&gt;
  
      &lt;h3 class="question"&gt;This is question number 2?&lt;/h3&gt;
      &lt;p class="answer"&gt;This is the answer to Q2.&lt;/p&gt;
  &lt;/body&gt;
  </code></pre>