The two types of web-services are,
Above entity contains details of Customer. As you can see, it stores Customer's FullName and Email. (Note: JSON is case-sensitive so email is different than Email or eMail ) If you know JavaScript multidimensional literal array, JSON will be easy for you (you can google it and learn javascript's array).
If we got above output, how do we access any particular value, say first Customer ' s Email,
var customer1Email = Customer[0].Email;//email@example.com
Similarly, we can access other values in javascript.
PHP functions for JSON,
- REST (Representational State Transfer) which is mostly based on JSON.
- SOAP (Simple Object Access Protocol) which is mostly based on WSDL (web-site description language)
JSON
JavaScript Object Notation is a lightweight data-interchange format. So, it's faster than SOAP (XML format). And hence, application runs faster using same web-service using JSON than XML. Example of JSON ,
{
"Customer": [
{ "FullName":"Some name" , "Email":"email@example.com" },
{ "FullName":"Other name" , "Email":"other@example.com" }
]
}
"Customer": [
{ "FullName":"Some name" , "Email":"email@example.com" },
{ "FullName":"Other name" , "Email":"other@example.com" }
]
}
Above entity contains details of Customer. As you can see, it stores Customer's FullName and Email. (Note: JSON is case-sensitive so email is different than Email or eMail ) If you know JavaScript multidimensional literal array, JSON will be easy for you (you can google it and learn javascript's array).
If we got above output, how do we access any particular value, say first Customer ' s Email,
var customer1Email = Customer[0].Email;//email@example.com
Similarly, we can access other values in javascript.
PHP functions for JSON,
- json_encode http://www.php.net/manual/en/function.json-encode.php (for encoding)
- json_decode http://www.php.net/manual/en/function.json-decode.php (for decoding)
No comments:
Post a Comment