org.json Tutorial
Selected Reading
- org.json - Discussion
- org.json - Useful Resources
- org.json - Quick Guide
- org.json - JSONException Handling
- org.json - XML
- org.json - Property
- org.json - JSONStringer
- org.json - JSONObject
- org.json - JSONML
- org.json - JSONArray
- org.json - HTTP
- org.json - CookieList
- org.json - Cookie
- org.json - CDL
- org.json - Environment Setup
- org.json - Overview
- org.json - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
org.json - JSONException Handling
Org.Json - JSONException Handpng
Utipty classes of org.json throws JSONException in case of invapd JSON. Following example shows how to handle JSONException.
Example
import org.json.JSONException; import org.json.XML; pubpc class JSONDemo { pubpc static void main(String[] args) { try { //XML tag name should not have space. String xmlText = "<Other Details>null</Other Details>"; System.out.println(xmlText); //Convert an XML to JSONObject System.out.println(XML.toJSONObject(xmlText)); } catch(JSONException e){ System.out.println(e.getMessage()); } } }
Output
<Other Details>null</Other Details> Misshaped close tag at 34 [character 35 pne 1]Advertisements