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

# json.encodePretty

> يسلسل Lua value إلى JSON string منسق وقابل للقراءة باستخدام Real JSON encoder. json.pretty مسجل على نفس function.

<div className="real-function-page">
  ```lua theme={null}
  json.encodePretty(value: any, options?: EncodeOptions): string
  ```

  ## الوسائط

  <ParamField path={"value"} type={"any"} required>
    Value الذي يتم encoded. nil و booleans و numbers و strings و tables و json.null يتم التعامل معها مباشرة. Unsupported Lua types يتم encoded كـ null إلا إذا كان errorOnUnsupported هو true.
  </ParamField>

  <ParamField path={"options"} type={"EncodeOptions"}>
    Optional encode options. json.encodePretty يقرأ نفس options مثل json.encode، ثم يفرض pretty على true. بدون options يستخدم two-space indent. number تضبط indent width مع clamp إلى 0.16، و string تضبط indent text، و table يمكنها ضبط sortKeys و emptyTableAsArray و errorOnUnsupported و encodeInvalidNumbersAsNull و maxDepth و indent.
  </ParamField>

  ## القيم الراجعة

  <ResponseField name={"json"} type={"string"}>
    Readable formatted JSON string. Encoding errors يتم رميها كـ Luau errors.
  </ResponseField>

  ## الأنواع

  ### EncodeOptions

  يتحكم في تسلسل JSON وتنسيقه.

  | Name                         | Type      | Required | الوصف                                                 |
  | ---------------------------- | --------- | -------- | ----------------------------------------------------- |
  | `pretty`                     | `boolean` | No       | لتمكين إخراج JSON المنسق والمتعدد الأسطر.             |
  | `sortKeys`                   | `boolean` | No       | فرز مفاتيح الكائنات قبل الترميز.                      |
  | `emptyTableAsArray`          | `boolean` | No       | ترميز جدول فارغ كمصفوفة بدلاً من كائن.                |
  | `errorOnUnsupported`         | `boolean` | No       | يثير خطأ بدلاً من استبدال قيم غير مدعومة.             |
  | `encodeInvalidNumbersAsNull` | `boolean` | No       | يشفر NaN والأرقام اللانهائية كـ JSON null.            |
  | `maxDepth`                   | `integer` | No       | يضبط الحد الأقصى لعمق التعشيش، المثبت من 1 إلى 4096.  |
  | `indent`                     | `string`  | No       | يضبط سلسلة المسافة البادئة، والتي تقتصر على 32 حرفًا. |

  ## مثال

  Encode JSON-compatible values كـ readable formatted JSON مع pretty output forced on.

  ```lua theme={null}
  local text = json.encodePretty({
      name = "Real",
      version = 1,
      features = json.array({ "docs", "examples" }),
      missing = json.null,
  }, {
      sortKeys = true,
  })

  print(text)
  ```
</div>
