Package net.bugreaper.modules.db.mapper
Class JsonToArrayMapper
java.lang.Object
net.bugreaper.modules.db.mapper.JsonToArrayMapper
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object[][]jsonToObjectArray(String json, boolean addOptionsAfterValue) Converts a flat JSON object into a two-dimensionalObject[][]array.
-
Method Details
-
jsonToObjectArray
Converts a flat JSON object into a two-dimensionalObject[][]array.Supports JSON keys with up to two options separated by ':'. The resulting row may contain 2–4 elements.
Each JSON entry is converted into one row of the resulting array:
{"key": value}→{"key", convertedValue}{"key:OPTION": value}→- if
addOptionsAfterValue == true→{"key", convertedValue, "OPTION"} - if
addOptionsAfterValue == false→{"key", "OPTION", convertedValue}
- if
Value conversion rules:
- Parameters:
json- the JSON string representing a flat objectaddOptionsAfterValue- controls the order of elements when a key contains options separated by':'. Iftrue, the order iskey, value, option. Iffalse, the order iskey, option, value.- Returns:
- a two-dimensional
Object[][]representation of the JSON object - Throws:
QueryBuilderException- if the provided JSON is not a flat JSON object or parsing/conversion fails
-