use of org.apache.pivot.serialization.MacroReader in project pivot by apache.
the class JSONSerializer method readObject.
/**
* Reads data from a JSON stream.
* <p> Processes macros at this level using {@link MacroReader}.
*
* @param reader The reader from which data will be read.
* @return One of the following types, depending on the content of the stream
* and the value of {@link #getType()}:
* <ul>
* <li>pivot.collections.Dictionary</li>
* <li>pivot.collections.Sequence</li>
* <li>java.lang.String</li>
* <li>java.lang.Number</li>
* <li>java.lang.Boolean</li>
* <li><tt>null</tt></li>
* <li>A JavaBean object</li>
* </ul>
* @throws IOException for any I/O related errors while reading.
* @throws SerializationException for any formatting errors in the data.
*/
public Object readObject(Reader reader) throws IOException, SerializationException {
Utils.checkNull(reader, "reader");
// Move to the first character
LineNumberReader lineNumberReader = new LineNumberReader(reader);
MacroReader macroReader = new MacroReader(lineNumberReader);
c = macroReader.read();
// Ignore BOM (if present)
if (c == 0xFEFF) {
c = macroReader.read();
}
// Read the root value
Object object;
try {
object = readValue(macroReader, type, type.getTypeName());
} catch (SerializationException exception) {
System.err.println("An error occurred while processing input at line number " + (lineNumberReader.getLineNumber() + 1));
throw exception;
}
return object;
}
Aggregations