Introducing to JSON
|
There are already lots of tutorials out there on handling JSON with PHP, but most of them don't go much deeper than throwing an array against json_encode and hoping for the best. This article aims to be a solid introduction into JSON and how to handle it correctly in combination with PHP. Also, readers who don't use PHP as their programming language can benefit from the first part that acts as a general overview on JSON.
JSON (JavaScript Object Notation) is a data exchange format that is both lightweight and human-readable (like XML, but without the bunch of markup around your actual payload). Its syntax is a subset of the JavaScript language that was standardized in 1999. If you want to find out more, visit the official website.
The cool thing about JSON is that you can handle it natively in JavaScript, so it acts as the perfect glue between server- and client-side application logic. Also, since the syntactical overhead (compared to XML) is very low, you need to transfer less bytes of ther wire. In modern web stacks, JSON has pretty much replaced XML as the de-factor payload format (aside from the Java world I suppose) and client side application frameworks like backbone.js make heavy use of it inside the model layer.
Before we start handling JSON in PHP, we need to take a short look at the JSON specification to understand how it is implemented and what's possible.
Introducing JSON
Since JSON is a subset of the JavaScript language, it shares all of its language constructs with its parent. In JSON, you can store unordered key/value combinations in objects or use arrays to preserve the order of values. This makes it easy to parse and to read, but also has some limitations. Since JSON only defines a small amount of data types, you can't transmit types like dates natively (you can, but you need to transform them into a string or a unix timestamp as an integer).
So, what datatypes does JSON support? It all boils down to strings, numbers, booleans and null. Of course, you can also supply objects or arrays as values.
Tutorial - MySQL to JSON Data Using PHP
Copy&Paste from: http://nitschinger.at/Handling-JSON-like-a-boss-in-PHP
POSTED BY juong |
Popular Posts
-
Rumi Ke Jawi 1. Convert rumi ke jawi secara online. senang sekali! 2. Lepas covert, copy dan paste kat microsoft word, 3. dan pilih font ...
-
1) Kaedah persenyawaan teknik bantuan Re-produktif (ART). Kaedah ART ialah kaedah yang dilakukan dengan memasukkan sperma/embrio ke dal...
-
Tulisan jawi amat diperlukan terutama bagi guru-guru yang menggunakan tulisan jawi sebagai medium untuk membuat soalan peperiksaan dan kepad...
-
Rumi ke Jawi versi Aplikasi Telefon (Buat masa sekarang, hanya pengguna telefon pintar Android sahaja boleh menggunakanya ). Aplikasi ini...
-
Salam, Nak cari Homestay @ penginapan berdekatan gua-gua di lenggong seperti Gua Puteri, Lenggong , anda boleh cari homestay M...
-
Mengetahui seseorang itu anak yang ke berapa dalam keluarga dengan menggunakan rumusan matematik. Sebagai contohnya: Dalam keluarga anda t...
-
Sebelum download Arabic Dotted / titik-titik, Aracbic font perlu di install terlebih dahulu. Install arabic font di sini Kalau dah install, ...
-
Cara Pengiraanya: Jumlah Stem Duti = [ ( Kadar Sewa Bulanan X 12 – 2400 ) / 250 ] X Jumlah Tahun Perjanjian Contoh pengiraan untuk sewaa...
-
Tafsir Al-Qur’an Surah Al-Mu’minuun (Orang-orang Yang Beriman) Surah Makkiyyah; surah ke 23: 118 ayat BismillaaHir rahmaanir rahiim :...
-
Pulau Langkawi atau Langkawi Island merupakan salah satu destinasi pelancongan yang paling popular di Malaysia. Pulau ini amat terkenal den...
Post a Comment