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

> Bir JSON string degerini parse eder ve Real JSON parser ve encoder ile readable formatted JSON olarak tekrar encode eder.

<div className="real-function-page">
  ```lua theme={null}
  json.format(json: string, encodeOptions?: EncodeOptions, decodeOptions?: DecodeOptions): string
  ```

  ## Argümanlar

  <ParamField path={"json"} type={"string"} required>
    Formatting oncesinde parse edilen JSON string. Function bu argument degerini string type checking ile okur.
  </ParamField>

  <ParamField path={"encodeOptions"} type={"EncodeOptions"}>
    Re-encode step icin optional encode options. json.format, json.encode ile ayni encode options degerlerini okur, sonra pretty degerini true yapar.
  </ParamField>

  <ParamField path={"decodeOptions"} type={"DecodeOptions"}>
    Input JSON parsing sirasinda kullanilan optional decode options. boolean useNull ayarlar. table useNull ve maxDepth ayarlayabilir.
  </ParamField>

  ## Dönüşler

  <ResponseField name={"formatted"} type={"string"}>
    Input parsing ve re-encoding sonrasi uretilen readable formatted JSON string.
  </ResponseField>

  ## Tipler

  ### EncodeOptions

  JSON serileştirmesini ve biçimlendirmesini kontrol eder.

  | Name                         | Type      | Required | Açıklama                                                               |
  | ---------------------------- | --------- | -------- | ---------------------------------------------------------------------- |
  | `pretty`                     | `boolean` | No       | Biçimlendirilmiş, çok satırlı JSON çıkışını etkinleştirir.             |
  | `sortKeys`                   | `boolean` | No       | Kodlamadan önce nesne anahtarlarını sıralar.                           |
  | `emptyTableAsArray`          | `boolean` | No       | Boş bir tabloyu nesne yerine dizi olarak kodlar.                       |
  | `errorOnUnsupported`         | `boolean` | No       | Desteklenmeyen değerleri değiştirmek yerine hata oluşturur.            |
  | `encodeInvalidNumbersAsNull` | `boolean` | No       | NaN'yi ve sonsuz sayıları JSON null olarak kodlar.                     |
  | `maxDepth`                   | `integer` | No       | 1'den 4096'ya kadar kenetlenmiş maksimum yuvalama derinliğini ayarlar. |
  | `indent`                     | `string`  | No       | 32 karakterle sınırlı girinti dizesini ayarlar.                        |

  ### DecodeOptions

  JSON ayrıştırma davranışını kontrol eder.

  | Name       | Type      | Required | Açıklama                                                               |
  | ---------- | --------- | -------- | ---------------------------------------------------------------------- |
  | `useNull`  | `boolean` | No       | Nil yerine kütüphanenin null sentinel'i ile JSON null'u temsil eder.   |
  | `maxDepth` | `integer` | No       | 1'den 4096'ya kadar kenetlenmiş maksimum yuvalama derinliğini ayarlar. |

  ## Örnek

  Existing JSON parse eder ve readable formatted JSON olarak re-encode eder.

  ```lua theme={null}
  local compact = '{"b":2,"a":1}'
  local formatted = json.format(compact, {
      pretty = true,
      sortKeys = true,
  }, {
      useNull = true,
  })

  print(formatted)
  ```
</div>
