> ## 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.clone

> ينسخ value عبر encoding باستخدام json.encode semantics ثم decoding للـ generated JSON مرة أخرى إلى Lua values.

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

  ## الوسائط

  <ParamField path={"value"} type={"any"} required>
    Value يتم encode و decode لها. Supported JSON values تعمل round-trip عبر JSON؛ unsupported types تتحول إلى null إلا إذا طلبت encode options خطأ.
  </ParamField>

  <ParamField path={"options"} type={"EncodeOptions"}>
    Optional encode options تمرر إلى encode step، مثل sortKeys و emptyTableAsArray و errorOnUnsupported و encodeInvalidNumbersAsNull و maxDepth و pretty و indent.
  </ParamField>

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

  <ResponseField name={"clone"} type={"any"}>
    Decoded value الناتجة من encoded JSON. Objects و arrays تصبح new tables مع JSON kind markers من decoder؛ JSON null values تتحول إلى json.null.
  </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 حرفًا. |

  ## مثال

  اعمل round-trip لقيمة JSON-compatible عبر json.encode و json.decode قبل تغيير nested values.

  ```lua theme={null}
  local original = {
      profile = { name = "Guest" },
  }

  local copy = json.clone(original)
  copy.profile.name = "Developer"

  print(original.profile.name)
  print(copy.profile.name)
  print(json.type(copy))
  ```
</div>
