Package org.ghotibeaun.json.converters
Interface JSONConverter
- All Superinterfaces:
Converter
- All Known Implementing Classes:
AbstractJSONConverter
public interface JSONConverter extends Converter
-
Method Summary
Modifier and Type Method Description <T> T
convertToClass(Class<T> targetClass, JSONObject json)
Convert a JSONObject into a Class instance<T> List<T>
convertToList(Class<T> targetItemClass, JSONArray array, Optional<ValueConverter<?>> valueConverter)
Deprecated.<T> List<T>
convertToList(JSONArray array, Optional<ValueConverter<?>> valueConverter, Optional<Class<?>> targetClass)
<T> T
convertValue(JSONValue<?> value, Optional<ValueConverter<?>> valueConverter, Optional<Class<?>> targetClass)
Methods inherited from interface org.ghotibeaun.json.converters.Converter
getConverterOptions
-
Method Details
-
convertToClass
Convert a JSONObject into a Class instance- Type Parameters:
T
- the Class type.- Parameters:
targetClass
- the concrete class to instantiate. It must implement or inherit from the Class type.json
- The JSONObject instance containing the data to initialize into the class instance- Returns:
- the specified Class instance
- Throws:
JSONConversionException
- thrown when an error occurs during the conversion
-
convertToList
@Deprecated <T> List<T> convertToList(Class<T> targetItemClass, JSONArray array, Optional<ValueConverter<?>> valueConverter) throws JSONConversionExceptionDeprecated.Convert a JSONArray into a List of values- Type Parameters:
T
- The Class Type.- Parameters:
targetItemClass
- The concrete class for each item in the list.array
- the JSONArray instance containing the data to initialize the list- Returns:
- a List of values
- Throws:
JSONConversionException
- thrown when an error occurs during conversion
-
convertToList
<T> List<T> convertToList(JSONArray array, Optional<ValueConverter<?>> valueConverter, Optional<Class<?>> targetClass) throws JSONConversionException- Throws:
JSONConversionException
-
convertValue
<T> T convertValue(JSONValue<?> value, Optional<ValueConverter<?>> valueConverter, Optional<Class<?>> targetClass) throws JSONConversionException- Throws:
JSONConversionException
-