Thursday, 23 October 2014

JSON BASICS


Features of JSON

  • It is an Java script object notation
  • JSON is Language independent
  • It is a self-descriptive and easy to understand


Comparison XML vs JSON

Much Like XML



  1. Both JSON and XML is plain text
  2. Both JSON and XML is "self-describing" (human readable)
  3. Both JSON and XML is hierarchical (values within values)
  4. Both JSON and XML can be fetched with an HttpRequest


Much Unlike XML




  1. JSON doesn't use end tag
  2. JSON is shorter
  3. JSON is quicker to read and write
  4. JSON can use arrays


Example of JSON and XML

Ex1:

<employees>
 <employee>  
<firstname>ravi</firstname>
<secondname> p</secondname>
</employee>
<employee>  
<firstname>shiva</firstname>
<secondname> m</secondname>
</employee>
</employees>


Ex 2:

JSOn is also same like xml but without end tag:
“employees”:[
 {“firstname”:”shiva”,”lastname”:”p”},
{“firstname”:”kishore”,”lastname”:”m”},
]

convert JSON string to java script object

You can convert JSON string to java script object in java script:

var jsonText=’{“employees”:[‘+
‘ {“firstname”:”shiva”,”lastname”:”p”},’+
‘{“firstname”:”kishore”,”lastname”:”m”},’+
‘]}’;

Var jsonobjet=JSON.parse(jsonText);


System.alert(jsonobjet. Employees[0].firstname+’return name of the first element’);

Basics of XML


It is basically designed for transport and store data.

Example :

<mail>
    <from> krish</from>
    <to>ravi</to>
   <subject>wish</subject>
   <body>Hi, how are you</boday>
</mail>

It is structured xml which wraps the data between tags
  • Root element
  • Child element
  • Attribute values must be quoted.


Name space for xml:

We may have two xml documents with same root element, when we mix those two we get confuse like below

<table>
  <name>shiva</name>
</table>
<table>
  <item> car</item>
</table>



For resolving this confusion they have provided name space :

<h:table>
<h:name>shiva</h:name>
</h:table>

<v:table>
<v:item> car</v:item>
</v:table>

But before going to use name space we must have to define in xml document


<?xml version="1.0" encoding="UTF-8"?>
<root>
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:name>shiva</h:name>
</h:table>

<v:table xmlns:v="http://www.w3schools.com/furniture">
<v:item> car</v:item>
</v:table>

</root>


Name space should be an URL, it will help you to understand the source of xml.

Types of Integrations in salesforce.com

                                                      TYPES OF INTEGRATION

1. Mashups

Placing external service into salesforce pages like google map into salesforce, visualforce pages.

2. Application Integration

Integration with middleware like (Enterprise Application Middleware like SOA ) creating abstraction layer between two applications.

3. Data integration

4. Data Cleansing

5. Salesforce Webservice in stranded way

XML:

(Extensible Markup Language): Designed especially for Web documents, XML is used to tag an
application’s code to specify the definition, transmission, validation, and interpretation of the tagged
data. To start an analogy, think of using XML to encode the message to be sent.

SOAP:

(Simple Object Access Protocol): This messaging protocol is used to encode the messages as
Web service requests and responses before they are sent across the network, most commonly via the
HTTP Protocol. A good way to think of SOAP is as the envelope for the message.

WSDL:

(Web Services Description Language): WSDL is an XML-formatted language that describes a
Web service as a collection of communication endpoints that can exchange messages, so that any
services that recognize those endpoints can communicate with each other. The WSDL specifies the
Delivery options available to the SOAP envelope. Salesforce is WSDL 1.1 compliant.

XML is used to tag data, SOAP transfers it, and the WSDL describes the available services
and their endpoint.

If you want weather some information, we will utilize services from the information provider.

Ex: In banking industry if they want to verify PANCARD, they will use Income Tax webservice or any other service provider who is having PAN card data.

Communication language between two systems:
  1. XML (Extensible Markup Language)
  2. JSON (Java Script Object Notation)
  3. Any other – custom defined 


Introduction about salesforce Integration and Their needs in real time

What is Integration?

Integration means combining two different services. so that they can work together or form a whole.

What is web service?

The term webservice describe standardized way of integrating web-based applications using xml, SOAP, WSDL.

Xml is used to tag the data.

SOAP is a protocol to transfer the data.

WSDL is to describe the service availability. 

Ways to connect salesforce?

There are Five ways to connect saleforce :

            




1. Native Desktop

In this Integration with lotus notes, Outlook, MS word …..

2. Mash-up from App exchange

Integrate with already available apps in app exchange.

3. Native ERP connectors

Integrate with already existing applications like ERP systems or other data base like Oracle, MS SQL…

4. Integration with middleware

By using middleware technology we do that like informatica, Apatar.

5. developer Toolkit 

Using web services to connecting with salesforce to .net, java, RUBY ........