Showing posts with the label Java

JSON with JAVA – Introduction to JSON – Part2

JAVA SE does not have any internal package for processing JSON data. We have to import an external library. There are many libraries available. You can choose any. I will use Json-simple1.1 here. This makes our first step, importing the lib. Importing the lib   Click here  and download the zip file containing the jar library and follow the following steps to import it into eclipse. 1. Extract the zip file. 2. Right Click on the project folder in the package explorer, hover over Build Path and click on Configure Build Path. 3. You will see a nice window. Go to the Libraries tab and click on Add External JARs. 4. Navigate to the extracted jar folder, select the library and press open/ok. 5. Press ok again and you are done. Exploring the lib The library contains parser and data structures to process the given JSON formatted string. The parser parses the JSON data from string/Reader to its own readable form. The data structures consist of JSONObject and JSONArray Cla

Introduction to JSON – Part 1

JSON is a data interchange format, frequently used for data exchange between clients and servers across the web. I am dividing this short tutorial series into three parts just to make it easy for you to understand. Part 1 is an introduction to JSON. It shows what is JSON, its structures are and how to write a JSON document. Part 2 explains How to process JSON in JAVA. The last part includes JSON Serialization. Hold your breath, a lot is coming up. JSON, short for J ava S cript O bject N otation is a lightweight format which makes data exchange more than easier. It is also used to store data. JSON is language independent. For example, you can make a JSON Object in java and send it to a C# program which will gracefully handle it. JavaScript object can be converted into a JSON object and vice versa. A JSON document can have two structures. JSON Object: A name value pair or a key value pair. Names/Keys are only strings however values are of various types. Name and value are separ

Inheritance In JAVA: Example

This is the second last section of the topic  Inheritance In OOP  where we will study some code snippets. This study will clarify the idea of how to achieve inheritance in JAVA and how it actually works. Without wasting any time and giving length to the post for no reason, let’s start rolling. Prerequisites:  To understand these snippets you should already know what inheritance is. If you don’t, don’t worry. I have a blog post, go  here . Overview : I have written a program named  Example  which depicts real life inheritance properties like a relationship between child and parent, child access to parent properties etc. The program consists of 4 very simple java classes which are extremely easy to understand. However, if you face any issue ping me in comments. I am always there for you.  Example ,  Bob ,  John,  and  Stephen . The bold faced letters are not names of some persons, in fact, these are names of classes which we are going to study here. In Java, to establish a chil