Professional Documents
Culture Documents
IT PROF 17
THIS LESSON COVERS THE FOLLOWING
TOPICS:
• A JSONObject can be represented by a String enclosed within curly braces with keys and values separated by a colon, and
pairs separated by a comma
The put() method is an overloaded method which accepts a key of type String and multiple types for the value.
CREATING A PROJECT IN NETBEANS:
1. Open the Netbeans Application.
2. From "File" menu ⇒ Choose "New Project...".
3. The "Choose Project" dialog pops up ⇒ Under
"Categories", choose "Java" ⇒ Under "Projects",
choose "Java Application" ⇒ "Next".
4. The "Name and Location" dialog pops up ⇒ Under
"Project Name", enter “YourCompleteNameProject"
⇒ In "Project Location", select a suitable directory to
save your works ⇒ Uncheck "Use Dedicated Folder
for Storing Libraries" ⇒ Uncheck "Create Main
class" ⇒ Finish. CONTINUE ON THE NEXT SLIDE…..
JSONOBJECT EXAMPLE:
• It's represented by a String wrapped within Square Brackets and consists of a collection of values separated by
commas
} catch (IOException e) {
e.printStackTrace();
}
}
}
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
named it
//JSON parser object to parse read file
JSONParser jsonParser = new JSONParser();
“ReadJSONExample”.
{
//Read JSON file
Object obj = jsonParser.parse(reader);
“ParseJSONURLExample”.
String url = "https://sparry-song.000webhostapp.com/students.php";
try {
InputStream is = new URL(url).openStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
side. }
sb.append((char) cp);
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
LESSON 4 – ACTIVITY LINK:
https://forms.gle/HyeAA5Ckgb6ToT7L6