1 package org.json.simple.parser;
3 import java.io.IOException;
6 * A simplified and stoppable SAX-like content handler for stream processing of JSON text.
8 * @see org.xml.sax.ContentHandler
9 * @see org.json.simple.parser.JSONParser#parse(java.io.Reader, ContentHandler, boolean)
11 * @author FangYidong<fangyidong@yahoo.com.cn>
13 public interface ContentHandler {
15 * Receive notification of the beginning of JSON processing.
16 * The parser will invoke this method only once.
18 * @throws ParseException
19 * - JSONParser will stop and throw the same exception to the caller when receiving this exception.
21 void startJSON() throws ParseException, IOException;
24 * Receive notification of the end of JSON processing.
26 * @throws ParseException
28 void endJSON() throws ParseException, IOException;
31 * Receive notification of the beginning of a JSON object.
33 * @return false if the handler wants to stop parsing after return.
34 * @throws ParseException
35 * - JSONParser will stop and throw the same exception to the caller when receiving this exception.
38 boolean startObject() throws ParseException, IOException;
41 * Receive notification of the end of a JSON object.
43 * @return false if the handler wants to stop parsing after return.
44 * @throws ParseException
48 boolean endObject() throws ParseException, IOException;
51 * Receive notification of the beginning of a JSON object entry.
53 * @param key - Key of a JSON object entry.
55 * @return false if the handler wants to stop parsing after return.
56 * @throws ParseException
58 * @see #endObjectEntry
60 boolean startObjectEntry(String key) throws ParseException, IOException;
63 * Receive notification of the end of the value of previous object entry.
65 * @return false if the handler wants to stop parsing after return.
66 * @throws ParseException
68 * @see #startObjectEntry
70 boolean endObjectEntry() throws ParseException, IOException;
73 * Receive notification of the beginning of a JSON array.
75 * @return false if the handler wants to stop parsing after return.
76 * @throws ParseException
80 boolean startArray() throws ParseException, IOException;
83 * Receive notification of the end of a JSON array.
85 * @return false if the handler wants to stop parsing after return.
86 * @throws ParseException
90 boolean endArray() throws ParseException, IOException;
93 * Receive notification of the JSON primitive values:
99 * @param value - Instance of the following:
105 * @return false if the handler wants to stop parsing after return.
106 * @throws ParseException
108 boolean primitive(Object value) throws ParseException, IOException;