// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/PersonalizedCatalogCommand.java
// public static class Catalog {
// 
//     private final Map<String, Object> data;
// 
//     private Catalog(Map<String, Object> data) {
//         this.data = data;
//     }
// 
//     @SuppressWarnings("unchecked")
//     public Observable<Video> videos() {
//         try {
//             return Observable.from((List<Integer>) data.get("videos")).map(Video::new);
//         } catch (Exception e) {
//             return Observable.error(e);
//         }
//     }
// 
//     public static Catalog fromJson(String json) {
//         return new Catalog(SimpleJson.jsonToMap(json));
//     }
// 
// }
// 
// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/common/SimpleJson.java
// public class SimpleJson {
// 
//     private static final SimpleJson INSTANCE = new SimpleJson();
// 
//     private SimpleJson() {
// 
//     }
// 
//     public static Map<String, Object> jsonToMap(String jsonString) {
//         return INSTANCE._jsonToMap(jsonString);
//     }
// 
//     public static String mapToJson(Map<String, ? extends Object> map) {
//         return INSTANCE._mapToJson(map);
//     }
// 
//     private final ObjectMapper objectMapper = new ObjectMapper();
//     private final ObjectReader objectReader = objectMapper.reader(Map.class);
// 
//     private Map<String, Object> _jsonToMap(String jsonString) {
//         try {
//             return objectReader.readValue(jsonString);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to parse JSON", e);
//         }
//     }
// 
//     private final ObjectWriter objectWriter = objectMapper.writerWithType(Map.class);
// 
//     private String _mapToJson(Map<String, ? extends Object> map) {
//         try {
//             return objectWriter.writeValueAsString(map);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to write JSON", e);
//         }
//     }
// }


import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixObservableCommand;
import io.netty.buffer.ByteBuf;
import io.reactivex.lab.gateway.clients.PersonalizedCatalogCommand.Catalog;
import io.reactivex.lab.gateway.clients.UserCommand.User;
import io.reactivex.lab.gateway.common.SimpleJson;
import io.reactivex.lab.gateway.loadbalancer.DiscoveryAndLoadBalancer;
import io.reactivex.netty.protocol.http.client.HttpClientRequest;
import io.reactivex.netty.protocol.http.sse.ServerSentEvent;
import netflix.ocelli.LoadBalancer;
import netflix.ocelli.rxnetty.HttpClientHolder;
import rx.Observable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

                userData.put("list_title", "Really quirky and over detailed list title!");
                userData.put("other_data", "goes_here");
                userData.put("videos", Arrays.asList(12345, 23456, 34567, 45678, 56789, 67890));
                return new Catalog(userData);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        });
    }

    public static class Catalog {

        private final Map<String, Object> data;

        private Catalog(Map<String, Object> data) {
            this.data = data;
        }

        @SuppressWarnings("unchecked")
        public Observable<Video> videos() {
            try {
                return Observable.from((List<Integer>) data.get("videos")).map(Video::new);
            } catch (Exception e) {
                return Observable.error(e);
            }
        }

        public static Catalog fromJson(String json) {
// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/PersonalizedCatalogCommand.java
// public static class Catalog {
// 
//     private final Map<String, Object> data;
// 
//     private Catalog(Map<String, Object> data) {
//         this.data = data;
//     }
// 
//     @SuppressWarnings("unchecked")
//     public Observable<Video> videos() {
//         try {
//             return Observable.from((List<Integer>) data.get("videos")).map(Video::new);
//         } catch (Exception e) {
//             return Observable.error(e);
//         }
//     }
// 
//     public static Catalog fromJson(String json) {
//         return new Catalog(SimpleJson.jsonToMap(json));
//     }
// 
// }
// 
// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/common/SimpleJson.java
// public class SimpleJson {
// 
//     private static final SimpleJson INSTANCE = new SimpleJson();
// 
//     private SimpleJson() {
// 
//     }
// 
//     public static Map<String, Object> jsonToMap(String jsonString) {
//         return INSTANCE._jsonToMap(jsonString);
//     }
// 
//     public static String mapToJson(Map<String, ? extends Object> map) {
//         return INSTANCE._mapToJson(map);
//     }
// 
//     private final ObjectMapper objectMapper = new ObjectMapper();
//     private final ObjectReader objectReader = objectMapper.reader(Map.class);
// 
//     private Map<String, Object> _jsonToMap(String jsonString) {
//         try {
//             return objectReader.readValue(jsonString);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to parse JSON", e);
//         }
//     }
// 
//     private final ObjectWriter objectWriter = objectMapper.writerWithType(Map.class);
// 
//     private String _mapToJson(Map<String, ? extends Object> map) {
//         try {
//             return objectWriter.writeValueAsString(map);
//         } catch (IOException e) {
//             throw new RuntimeException("Unable to write JSON", e);
//         }
//     }
// }


// Path: reactive-lab-gateway/src/main/java/io/reactivex/lab/gateway/clients/PersonalizedCatalogCommand.java
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixObservableCommand;
import io.netty.buffer.ByteBuf;
import io.reactivex.lab.gateway.clients.PersonalizedCatalogCommand.Catalog;
import io.reactivex.lab.gateway.clients.UserCommand.User;
import io.reactivex.lab.gateway.common.SimpleJson;
import io.reactivex.lab.gateway.loadbalancer.DiscoveryAndLoadBalancer;
import io.reactivex.netty.protocol.http.client.HttpClientRequest;
import io.reactivex.netty.protocol.http.sse.ServerSentEvent;
import netflix.ocelli.LoadBalancer;
import netflix.ocelli.rxnetty.HttpClientHolder;
import rx.Observable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


                userData.put("list_title", "Really quirky and over detailed list title!");
                userData.put("other_data", "goes_here");
                userData.put("videos", Arrays.asList(12345, 23456, 34567, 45678, 56789, 67890));
                return new Catalog(userData);
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }
        });
    }

    public static class Catalog {

        private final Map<String, Object> data;

        private Catalog(Map<String, Object> data) {
            this.data = data;
        }

        @SuppressWarnings("unchecked")
        public Observable<Video> videos() {
            try {
                return Observable.from((List<Integer>) data.get("videos")).map(Video::new);
            } catch (Exception e) {
                return Observable.error(e);
            }
        }

        public static Catalog fromJson(String json) {
            return new Catalog(SimpleJson.jsonToMap(json));