当前位置: 首页>>代码示例>>Java>>正文


Java LoganSquare.parseMap方法代码示例

本文整理汇总了Java中com.bluelinelabs.logansquare.LoganSquare.parseMap方法的典型用法代码示例。如果您正苦于以下问题:Java LoganSquare.parseMap方法的具体用法?Java LoganSquare.parseMap怎么用?Java LoganSquare.parseMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bluelinelabs.logansquare.LoganSquare的用法示例。


在下文中一共展示了LoganSquare.parseMap方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: simpleObjectMapWithNulls

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleObjectMapWithNulls() {
    String json = "{\"obj1\":{\"date\":\"2015-02-21T18:45:50.748+0000\",\"string\":\"testString\",\"test_double\":342.0,\"test_double_obj\":345.0,\"test_float\":898.0,\"test_float_obj\":382.0,\"test_int\":32,\"test_int_obj\":323,\"test_long\":932,\"test_long_obj\":3920,\"test_string\":\"anotherTestString\"}," +
            "\"obj2\":{\"date\":\"2015-02-22T18:45:50.748+0000\",\"string\":\"testString2\",\"test_double\":342.0,\"test_double_obj\":345.0,\"test_float\":898.0,\"test_float_obj\":382.0,\"test_int\":32,\"test_int_obj\":323,\"test_long\":932,\"test_long_obj\":3920,\"test_string\":\"anotherTestString\"}," +
            "\"obj3\":{\"date\":null,\"string\":\"testString2\",\"test_double\":342.0,\"test_double_obj\":null,\"test_float\":898.0,\"test_float_obj\":null,\"test_int\":32,\"test_int_obj\":null,\"test_long\":932,\"test_long_obj\":null,\"test_string\":null}," +
            "\"obj4\":null}";

    String reserialized = null;
    try {
        Map<String, SimpleModel> simpleModelMap = LoganSquare.parseMap(json, SimpleModel.class);
        TreeMap<String, SimpleModel> sortedMap = new TreeMap<>();
        sortedMap.put("obj1", simpleModelMap.get("obj1"));
        sortedMap.put("obj2", simpleModelMap.get("obj2"));
        sortedMap.put("obj3", simpleModelMap.get("obj3"));
        sortedMap.put("obj4", simpleModelMap.get("obj4"));

        reserialized = LoganSquare.serialize(sortedMap, SimpleModel.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RoundTripTests.java

示例2: simpleObjectMapWithoutNulls

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleObjectMapWithoutNulls() {
    String json = "{\"obj1\":{\"date\":\"2015-02-21T18:45:50.748+0000\",\"string\":\"testString\",\"test_double\":342.0,\"test_double_obj\":345.0,\"test_float\":898.0,\"test_float_obj\":382.0,\"test_int\":32,\"test_int_obj\":323,\"test_long\":932,\"test_long_obj\":3920,\"test_string\":\"anotherTestString\"}," +
            "\"obj2\":{\"date\":\"2015-02-22T18:45:50.748+0000\",\"string\":\"testString2\",\"test_double\":342.0,\"test_double_obj\":345.0,\"test_float\":898.0,\"test_float_obj\":382.0,\"test_int\":32,\"test_int_obj\":323,\"test_long\":932,\"test_long_obj\":3920,\"test_string\":\"anotherTestString\"}," +
            "\"obj3\":{\"string\":\"testString2\",\"test_double\":342.0,\"test_float\":898.0,\"test_int\":32,\"test_long\":932}," +
            "\"obj4\":null}";

    String reserialized = null;
    try {
        Map<String, SimpleModelWithoutNullObjects> simpleModelMap = LoganSquare.parseMap(json, SimpleModelWithoutNullObjects.class);
        TreeMap<String, SimpleModelWithoutNullObjects> sortedMap = new TreeMap<>();
        sortedMap.put("obj1", simpleModelMap.get("obj1"));
        sortedMap.put("obj2", simpleModelMap.get("obj2"));
        sortedMap.put("obj3", simpleModelMap.get("obj3"));
        sortedMap.put("obj4", simpleModelMap.get("obj4"));

        reserialized = LoganSquare.serialize(sortedMap, SimpleModelWithoutNullObjects.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RoundTripTests.java

示例3: parseList

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Nullable
public static List parseList(@NonNull InputStream stream) {
    List list = null;
    JsonStructure jsonStructure = CandyBarApplication.getConfiguration().getWallpaperJsonStructure();

    try {
        if (jsonStructure.getArrayName() == null) {
            list = LoganSquare.parseList(stream, Map.class);
        } else {
            Map<String, List> map = LoganSquare.parseMap(stream, List.class);
            list = map.get(jsonStructure.getArrayName());
        }
    } catch (IOException e) {
        LogUtil.e(Log.getStackTraceString(e));
    }
    return list;
}
 
开发者ID:danimahardhika,项目名称:candybar-library,代码行数:18,代码来源:JsonHelper.java

示例4: stringMap

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void stringMap() {
    String json = "{\"key1\":\"val1\",\"key2\":\"val2\",\"key3\":\"val3\"}";

    String reserialized = null;
    try {
        Map<String, String> map = new TreeMap<>(LoganSquare.parseMap(json, String.class));
        reserialized = LoganSquare.serialize(map, String.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RoundTripTests.java

示例5: intMap

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void intMap() {
    String json = "{\"key1\":1,\"key2\":2,\"key3\":3}";

    String reserialized = null;
    try {
        Map<String, Integer> map = new TreeMap<>(LoganSquare.parseMap(json, Integer.class));
        reserialized = LoganSquare.serialize(map, Integer.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RoundTripTests.java

示例6: floatMap

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void floatMap() {
    String json = "{\"key1\":1.4,\"key2\":2.0,\"key3\":3.224}";

    String reserialized = null;
    try {
        Map<String, Float> map = new TreeMap<>(LoganSquare.parseMap(json, Float.class));
        reserialized = LoganSquare.serialize(map, Float.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RoundTripTests.java

示例7: booleanMap

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void booleanMap() {
    String json = "{\"key1\":true,\"key2\":true,\"key3\":false}";

    String reserialized = null;
    try {
        Map<String, Boolean> map = new TreeMap<>(LoganSquare.parseMap(json, Boolean.class));
        reserialized = LoganSquare.serialize(map, Boolean.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RoundTripTests.java

示例8: mixedObjectMap

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void mixedObjectMap() {
    String json = "{\"key1\":true,\"key2\":1,\"key3\":1.02,\"key4\":1002020,\"key5\":\"test2\",\"key6\":{\"subkey1\":1,\"subkey2\":\"string\"},\"key7\":[1,2,3]}";

    String reserialized = null;
    try {
        Map<String, Object> map = new TreeMap<>(LoganSquare.parseMap(json, Object.class));
        reserialized = LoganSquare.serialize(map, Object.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:RoundTripTests.java

示例9: simpleObjectMap

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleObjectMap() {
    String json = "{\"obj1\":{\"date\":\"2015-02-21T18:45:50.748+0000\",\"string\":\"testString\",\"test_double\":342.0,\"test_double_obj\":345.0,\"test_float\":898.0,\"test_float_obj\":382.0,\"test_int\":32,\"test_int_obj\":323,\"test_long\":932,\"test_long_obj\":3920,\"test_string\":\"anotherTestString\"}," +
            "\"obj2\":{\"date\":\"2015-02-22T18:45:50.748+0000\",\"string\":\"testString2\",\"test_double\":342.0,\"test_double_obj\":345.0,\"test_float\":898.0,\"test_float_obj\":382.0,\"test_int\":32,\"test_int_obj\":323,\"test_long\":932,\"test_long_obj\":3920,\"test_string\":\"anotherTestString\"}}";

    String reserialized = null;
    try {
        Map<String, SimpleModel> simpleModelMap = new TreeMap<>(LoganSquare.parseMap(json, SimpleModel.class));
        reserialized = LoganSquare.serialize(simpleModelMap, SimpleModel.class);
    } catch (Exception ignored) { }

    ASSERT.that(json.equals(reserialized)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:RoundTripTests.java

示例10: convert

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override
public Object convert(ResponseBody value) throws IOException {
    try {
        InputStream is = value.byteStream();
        if (type instanceof Class) {
            // Plain object conversion
            return LoganSquare.parse(is, (Class<?>) type);

        } else if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) type;
            Type[] typeArguments = parameterizedType.getActualTypeArguments();
            Type firstType = typeArguments[0];

            Type rawType = parameterizedType.getRawType();
            if (rawType == Map.class) {
                return LoganSquare.parseMap(is, (Class<?>) typeArguments[1]);

            } else if (rawType == List.class) {
                return LoganSquare.parseList(is, (Class<?>) firstType);

            } else {
                // Generics
                return LoganSquare.parse(is, parameterizedTypeOf(type));
            }
        }
        return null;

    } finally {
        // Close the response body after being done with it
        value.close();
    }
}
 
开发者ID:mannodermaus,项目名称:retrofit-logansquare,代码行数:33,代码来源:LoganSquareResponseBodyConverter.java


注:本文中的com.bluelinelabs.logansquare.LoganSquare.parseMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。