src/main/java/tech/zettervall/openlibrary/rxclient/models/Read.java
/**
     * Convert Read API response to Read.
     */
Convert Read API response to Read.
Convert Read API response to Read .
public static Read jsonConverter(JsonObject obj) {
        List<Record> records = new ArrayList<>();
        if (obj.get("records").isJsonArray()) {
            for (JsonElement e : obj.get("records").getAsJsonArray()) {
                records.add(new Gson().fromJson(e, Record.class));
            }
        } else {
            obj.get("records").getAsJsonObject().keySet().forEach(
                    key -> records.add(new Gson().fromJson(obj.get("records").getAsJsonObject().get(key), Record.class)));
        }
        List<Item> items = new ArrayList<>();
        for (JsonElement e : obj.get("items").getAsJsonArray()) {
            items.add(new Gson().fromJson(e, Item.class));
        }
        return new Read(records.toArray(new Record[0]), items.toArray(new Item[0]));
    }
public static Read jsonConverter ( JsonObject obj ) { List < Record > records = new ArrayList < > ( ) ; if ( obj . get ( "records" ) . isJsonArray ( ) ) { for ( JsonElement e : obj . get ( "records" ) . getAsJsonArray ( ) ) { records . add ( new Gson ( ) . fromJson ( e , Record . class ) ) ; } } else { obj . get ( "records" ) . getAsJsonObject ( ) . keySet ( ) . forEach ( key -> records . add ( new Gson ( ) . fromJson ( obj . get ( "records" ) . getAsJsonObject ( ) . get ( key ) , Record . class ) ) ) ; } List < Item > items = new ArrayList < > ( ) ; for ( JsonElement e : obj . get ( "items" ) . getAsJsonArray ( ) ) { items . add ( new Gson ( ) . fromJson ( e , Item . class ) ) ; } return new Read ( records . toArray ( new Record [ 0 ] ) , items . toArray ( new Item [ 0 ] ) ) ; }
Convert Read API response to Read.
Convert Read API response to Read .