PHP JSON ma’lumotnomasi
PHP JSON kirish
JSON kengaytmasi JavaScript Object Notation ma’lumotlar almashish formatini amalga oshiradi.
O‘rnatish
PHP 5.2 dan JSON funksiyalari sukut bo‘yicha yoqilgan. Ushbu funksiyalardan foydalanish uchun o‘rnatish kerak emas.
PHP JSON funksiyalari
| Function | Tavsif |
|---|---|
| json_decode() | JSON stringni dekodlaydi |
| json_encode() | Qiymatni JSON formatiga kodlash |
| json_last_error() | Oxirgi sodir bo‘lgan xatoni qaytaradi |
| json_last_error_msg() | Oxirgi json_encode() yoki json_decode() chaqiruvining xato stringini qaytaradi |
| json_validate() | Stringda yaroqli JSON mavjudligini tekshiradi (PHP 8.3) |
PHP oldindan belgilangan JSON doimiylari
| Constant | Type | Tavsif |
|---|---|---|
| JSON_ERROR_NONE | Integer | Hech qanday xato yuz bermadi |
| JSON_ERROR_DEPTH | Integer | Stekning maksimal chuqurligidan oshib ketildi |
| JSON_ERROR_STATE_MISMATCH | Integer | Invalid/Malformed JSON |
| JSON_ERROR_CTRL_CHAR | Integer | Control character error |
| JSON_ERROR_SYNTAX | Integer | Syntax error |
| JSON_ERROR_UTF8 | Integer | Malformed UTF-8 characters |
| JSON_ERROR_RECURSION | Integer | Invalid recursive reference values |
| JSON_ERROR_INF_OR_NAN | Integer | Noto‘g‘ri NAN yoki INF qiymatlari |
| JSON_ERROR_UNSUPPORTED_TYPE | Integer | Invalid type |
| JSON_ERROR_INVALID_PROPERTY_NAME | Integer | Xususiyat nomi noto‘g‘ri |
| JSON_ERROR_UTF16 | Integer | Malformed UTF-16 characters |
| JSON_BIGINT_AS_STRING | Integer | |
| JSON_OBJECT_AS_ARRAY | Integer | |
| JSON_HEX_TAG | Integer | Barcha < va > \u003C va \u003E ga aylantiriladi |
| JSON_HEX_AMP | Integer | Hamma & ga aylantirildi \u0026 |
| JSON_HEX_APOS | Integer | Hammasi \u0027 ga aylantirildi |
| JSON_HEX_QUOT | Integer | Hammasi "\u0022 ga aylantiriladi |
| JSON_FORCE_OBJECT | Integer | |
| JSON_NUMERIC_CHECK | Integer | Raqamli stringlarni raqamlar sifatida kodlaydi |
| JSON_PRETTY_PRINT | Integer | Qaytarilgan ma’lumotni formatlash uchun bo‘sh joydan foydalaning |
| JSON_UNESCAPED_SLASHES | Integer | / belgisini ekranlamaslik |
| JSON_PARTIAL_OUTPUT_ON_ERROR | Integer | |
| JSON_PRESERVE_ZERO_FRACTION | Integer | |
| JSON_UNESCAPED_LINE_TERMINATORS | Integer | |
| JSON_INVALID_UTF8_IGNORE | Integer | Ignore invalid UTF-8 characters |
| JSON_INVALID_UTF8_SUBSTITUTE | Integer | Yaroqsiz UTF-8 belgilarini \0xfffd ga aylantiring |
| JSON_THROWN_ON_ERROR | Integer |
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
