> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 驗證 JSON

> 傳送 JSON 以驗證格式是否正確

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

<PlansAvailable plans={["premium"]} maxPackRequired={false} />

傳送 JSON 以驗證格式是否正確。
你可以透過線上檢查工具（例如 [https://jsonlint.com/](https://jsonlint.com/)）或 [Postman](/testing/postman) 來驗證你的 JSON。

如果你使用 Bubble、Make 之類的無程式碼工具，或收到 500 「Bad Request」回應，此端點對於除錯 JSON 請求非常有用。

## 標頭參數

<HeaderAPI noProfileKey={true} />

<ul class="custom-bullets">
  <li>以純文字形式傳送資料。如果使用 Postman，請務必將類型選為「Text」。</li>
  <li>設定 `"Content-Type": "text/plain"`。</li>
</ul>

## 請求範例

將任何 JSON 傳送到此端點即可進行驗證。

以下是使用 Postman 傳送無效 JSON 的範例。你能看出問題嗎？就是第二個參數 `platforms` 結尾缺少逗號。

請務必將標頭 `Content-Type` 設為 `text/plain`，並在傳送時選擇「Text」。

<img class="center" src="https://mintcdn.com/ayrshare-docs/Nmrhj2Gh7WSf62Bh/images/apis/validate/json.webp?fit=max&auto=format&n=Nmrhj2Gh7WSf62Bh&q=85&s=97c9aba02aba44ee47247c295523d259" alt="Postman Validate JSON" width="1200" height="610" data-path="images/apis/validate/json.webp" />

<RequestExample />

<ResponseExample>
  ```json 200: OK Valid JSON theme={"system"}
  {
      "status": "success",
      "message": "Valid JSON. Nice Job!"
  }
  ```

  ```json 400: Bad Request Invalid JSON theme={"system"}
  {
    "status": "error",
    "message": "JSON is not valid. Unexpected end of JSON input while parsing near '{\"test\": \"happy}'"
  }
  ```
</ResponseExample>
