Package com.cedarsoftware.io
Interface JsonClassReader<T>
- Type Parameters:
T- the type of object this reader produces
- All Known Subinterfaces:
JsonReader.JsonClassReader<T>
- All Known Implementing Classes:
RecordFactory.RecordReader
public interface JsonClassReader<T>
Implement this interface to add a custom JSON reader for a specific class.
Recommendation: Use ClassFactory instead when possible - it allows you to
instantiate and read the JSON object in one operation, which is simpler for most use cases.
Register your custom reader using ReadOptionsBuilder.addCustomReaderClass(Class, JsonClassReader).
- Author:
- John DeRegnaucourt (jdereg@gmail.com)
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Method Summary
-
Method Details
-
read
Read a custom object from JSON. Only process the non-structural values for any given reader, and push the structural elements (non-primitive fields) onto the resolver's stack to be processed. This allows them to be processed by a standard processor (array, Map, Collection) or another custom factory or reader that handles the "next level." You can handle sub-objects here if needed.- Parameters:
jsonObj- Object being read. Could be a fundamental JSON type (String, long, boolean, double, null) or a JsonObject containing the parsed JSON structure.resolver- Provides access to push non-primitive items onto the stack for further processing, as well as access to ReadOptions, Converter, and reference tracking.- Returns:
- Java Object that you filled out with values from the passed in jsonObj.
-