<< Chapter < Page Chapter >> Page >

What you can expect

This book will explain how to use the following classes:

  • JSONObject
  • JSONValue
  • JSONParser
  • JSONArray
  • ParseException

An investigation into the use of the other classes and interfaces will be left as "an exercise for the student" .

Run the program

I encourage you to copy the code from Listing 1 . Execute the code and confirm that you get the same results as those shown in Figure 1 . Experiment with the code, making changes, and observing the results of your changes. Make certain that youcan explain why your changes behave as they do.

Complete program listing

Listing 1 provides the source code for the program named Code.java .

Listing 1 . Program named Code.java. /******************************************************************** Copyright 2016, R.G.BaldwinEstablishes the position of each of the json-simple classes in the class hierarchy by getting and displaying the superclass of eachclass. Produces the following output:ItemList: class java.lang.Object JSONArray: class java.util.ArrayListJSONObject: class java.util.HashMap JSONParser: class java.lang.ObjectJSONValue: class java.lang.Object ParseException: class java.lang.ExceptionYytoken: class java.lang.Object Tested with Java 8, Windows 7, and json-simple-1.1.1.jar********************************************************************/ import org.json.simple.JSONObject;import org.json.simple.JSONArray; import org.json.simple.JSONValue;import org.json.simple.ItemList; import org.json.simple.JSONAware;import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException;import org.json.simple.parser.Yytoken; class Code{public static void main(String[] args){System.out.println("ItemList: " + new ItemList().getClass().getSuperclass());System.out.println("JSONArray: " + new JSONArray().getClass().getSuperclass());System.out.println("JSONObject: " + new JSONObject().getClass().getSuperclass());System.out.println("JSONParser: " + new JSONParser().getClass().getSuperclass());System.out.println("JSONValue: " + new JSONValue().getClass().getSuperclass());System.out.println("ParseException: " + new ParseException(ParseException.ERROR_UNEXPECTED_CHAR).getClass().getSuperclass()); System.out.println("Yytoken: " +new Yytoken(Yytoken.TYPE_COLON,":"). getClass().getSuperclass());}//end main }//end class code


This section contains a variety of miscellaneous information.

Housekeeping material
  • Module name: Json0210: Structure of the json-simple JavaLibrary
  • File: Json0210.htm
  • Published: 05/30/16

Financial : Although the Connexions site makes it possible for you to download a PDF file for thismodule at no charge, and also makes it possible for you to purchase a pre-printed version of the PDF file, you should beaware that some of the HTML elements in this module may not translate well into PDF.

I also want you to know that, I receive no financial compensation from the Connexions website even if you purchase the PDF version of the module.

In the past, unknown individuals have copied my modules from cnx.org, converted them to Kindle books, and placed them for sale on Amazon.com showing me as the author. Ineither receive compensation for those sales nor do I know who does receive compensation. If you purchase such a book, please beaware that it is a copy of a module that is freely available on cnx.org and that it was made and published withoutmy prior knowledge.

Affiliation : I am a professor of Computer Information Technology at Austin Community College in Austin, TX.


Questions & Answers

a perfect square v²+2v+_
Dearan Reply
kkk nice
Abdirahman Reply
algebra 2 Inequalities:If equation 2 = 0 it is an open set?
Kim Reply
or infinite solutions?
Embra Reply
if |A| not equal to 0 and order of A is n prove that adj (adj A = |A|
Nancy Reply
rolling four fair dice and getting an even number an all four dice
ramon Reply
Kristine 2*2*2=8
Bridget Reply
Differences Between Laspeyres and Paasche Indices
Emedobi Reply
No. 7x -4y is simplified from 4x + (3y + 3x) -7y
Mary Reply
is it 3×y ?
Joan Reply
J, combine like terms 7x-4y
Bridget Reply
im not good at math so would this help me
Rachael Reply
how did I we'll learn this
Noor Reply
f(x)= 2|x+5| find f(-6)
Prince Reply
f(n)= 2n + 1
Samantha Reply
Need to simplify the expresin. 3/7 (x+y)-1/7 (x-1)=
Crystal Reply
. After 3 months on a diet, Lisa had lost 12% of her original weight. She lost 21 pounds. What was Lisa's original weight?
Chris Reply
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
can nanotechnology change the direction of the face of the world
Prasenjit Reply
At high concentrations (>0.01 M), the relation between absorptivity coefficient and absorbance is no longer linear. This is due to the electrostatic interactions between the quantum dots in close proximity. If the concentration of the solution is high, another effect that is seen is the scattering of light from the large number of quantum dots. This assumption only works at low concentrations of the analyte. Presence of stray light.
Ali Reply
the Beer law works very well for dilute solutions but fails for very high concentrations. why?
bamidele Reply
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Got questions? Join the online conversation and get instant answers!
QuizOver.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?