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


Java LoganSquare.parse方法代码示例

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


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

示例1: nestedCollection

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void nestedCollection() {
    List<ArrayList<Set<Map<String, List<String>>>>>[] array = (List<ArrayList<Set<Map<String, List<String>>>>>[])new List<?>[] {getStringListMapSetArrayListList() };

    NestedCollectionModel model = new NestedCollectionModel();
    model.crazyCollection = array;

    String json = null;
    try {
        json = LoganSquare.serialize(model);
    } catch (Exception e) {
        e.printStackTrace();
    }

    ASSERT.that(json).isNotNull();

    NestedCollectionModel reconstructedModel = null;
    try {
        reconstructedModel = LoganSquare.parse(json, NestedCollectionModel.class);
    } catch (Exception ignored) { }

    // Comparing the json doesn't work so well on arrays, since they could be reordered. We'll compare the output instead.
    ASSERT.that(model.equals(reconstructedModel)).isTrue();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:RoundTripTests.java

示例2: test_Parse_JSONRepo_ParsesRepoDTO

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Frutilla(
        Given = "A single GitHub repo from a JSON file",
        When = "Parsing this content with LoganSquare",
        Then = "It should have parsed a repo named \"git-consortium\""
)
@Test
public void test_Parse_JSONRepo_ParsesRepoDTO() throws IOException {
    String lsRepoData;
    Given:
    {
        lsRepoData = mLocalifyClient.localify().loadRawFile(R.raw.repo_octocat);
    }

    DTORepo loRepoDTO;
    When:
    {
        loRepoDTO = LoganSquare.parse(lsRepoData, DTORepo.class);
    }

    Then:
    {
        assertThat(loRepoDTO).isNotNull();
        assertThat(loRepoDTO.name).isEqualTo("git-consortium");
    }
}
 
开发者ID:RoRoche,项目名称:AndroidStarterAlt,代码行数:26,代码来源:TestParsing.java

示例3: fromBody

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override public Object fromBody(TypedInput body, Type type) throws ConversionException {
    try {
        // Check if the type contains a parametrized list
        if (ParameterizedType.class.isAssignableFrom(type.getClass())) {
            // Grab the actual type parameter from the parametrized list and delegate to LoganSquare
            ParameterizedType parameterized = (ParameterizedType) type;
            return LoganSquare.parseList(body.in(), (Class) parameterized.getActualTypeArguments()[0]);

        } else {
            // Single elements get parsed immediately
            return LoganSquare.parse(body.in(), (Class) type);
        }
    } catch (Exception e) {
        throw new ConversionException(e);
    }
}
 
开发者ID:getsadzeg,项目名称:AreYouAlive,代码行数:17,代码来源:LoganSquareConverter.java

示例4: shouldBeSameObjectAfterJsonParsing

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void shouldBeSameObjectAfterJsonParsing() throws IOException {
    // given
    SkuDetails originalSku = new SkuDetails();

    originalSku.setCurrency("EUR");
    originalSku.setDescription("description");
    originalSku.setPriceText("priceText");
    originalSku.setPriceValueMicros(BigDecimal.valueOf(1230000));
    originalSku.setProductId("productId");
    originalSku.setSubscription("sub");
    originalSku.setTitle("title");

    // when
    String json = LoganSquare.serialize(originalSku);
    SkuDetails outputSku = LoganSquare.parse(json, SkuDetails.class);

    // then
    assertThat(outputSku).isEqualTo(originalSku);
}
 
开发者ID:pavlospt,项目名称:RxIAPv3,代码行数:21,代码来源:SkuDetailsJsonParsingTest.java

示例5: fromBody

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override public Object fromBody(TypedInput body, Type type) throws ConversionException {
	try {
		// Check if the type contains a parametrized list
		if (ParameterizedType.class.isAssignableFrom(type.getClass())) {
			// Grab the actual type parameter from the parametrized list and delegate to LoganSquare
			ParameterizedType parameterized = (ParameterizedType) type;
			return LoganSquare.parseList(body.in(), (Class) parameterized.getActualTypeArguments()[0]);

		} else {
			// Single elements get parsed immediately
			return LoganSquare.parse(body.in(), (Class) type);
		}
	} catch (Exception e) {
		throw new ConversionException(e);
	}
}
 
开发者ID:yongjhih,项目名称:converter-logansquare-retrofit,代码行数:17,代码来源:LoganSquareConverter.java

示例6: fromBody

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override
public Object fromBody(TypedInput body, Type type) throws ConversionException {
    try {
        // Check if the type contains a parametrized list
        if (ParameterizedType.class.isAssignableFrom(type.getClass())) {
            // Grab the actual type parameter from the parametrized list and delegate to LoganSquare
            ParameterizedType parameterized = (ParameterizedType) type;
            return LoganSquare.parseList(body.in(), (Class) parameterized.getActualTypeArguments()[0]);

        } else {
            // Single elements get parsed immediately
            return LoganSquare.parse(body.in(), (Class) type);
        }
    } catch (Exception e) {
        throw new ConversionException(e);
    }
}
 
开发者ID:dinosaurwithakatana,项目名称:hacker-news-android,代码行数:18,代码来源:LoganSquareConvertor.java

示例7: parse

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override
protected int parse(String json) {
    try {
        Response response = LoganSquare.parse(json, Response.class);
        return response.users.size();
    } catch (Exception e) {
        return 0;
    } finally {
        System.gc();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:LoganSquareParser.java

示例8: simpleGenericObject

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleGenericObject() {
    String json = "{\"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_nested_generic\":{\"test_double\":0.0,\"test_float\":0.2,\"test_int\":10,\"test_long\":0},\"test_string\":\"anotherTestString\",\"test_t\":\"generic string!\"}";

    String reserialized = null;
    try {
        ParameterizedType<SimpleGenericModel<String>> parameterizedType = new ParameterizedType<SimpleGenericModel<String>>() { };
        SimpleGenericModel<String> simpleModel = LoganSquare.parse(json, parameterizedType);
        reserialized = LoganSquare.serialize(simpleModel, parameterizedType);
    } catch (Exception ignored) { }

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

示例9: simpleGenericStringObject

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleGenericStringObject() {
    String json = "{\"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_nested_generic\":{\"test_double\":0.0,\"test_float\":0.2,\"test_int\":10,\"test_long\":0},\"test_string\":\"anotherTestString\",\"test_t\":\"generic string!\"}";

    String reserialized = null;
    try {
        SimpleGenericStringModel model = LoganSquare.parse(json, SimpleGenericStringModel.class);
        reserialized = LoganSquare.serialize(model);
    } catch (Exception ignored) { }

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

示例10: simpleModelWithGenericField

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleModelWithGenericField() {
    String json = "{\"generic_model\":{\"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_nested_generic\":{\"test_double\":0.0,\"test_float\":0.2,\"test_int\":10,\"test_long\":0},\"test_string\":\"anotherTestString\",\"test_t\":\"generic string!\"},\"string\":\"hi\"}";

    String reserialized = null;
    try {
        SimpleModelWithGenericField model = LoganSquare.parse(json, SimpleModelWithGenericField.class);
        reserialized = LoganSquare.serialize(model);
    } catch (Exception ignored) { }

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

示例11: simpleGenericExtendsStringObject

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleGenericExtendsStringObject() {
    String json = "{\"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\",\"test_t\":\"generic string!\"}";

    String reserialized = null;
    try {
        ParameterizedType<SimpleGenericModelWithExtends<String>> parameterizedType = new ParameterizedType<SimpleGenericModelWithExtends<String>>() { };
        SimpleGenericModelWithExtends<String> model = LoganSquare.parse(json, parameterizedType);
        reserialized = LoganSquare.serialize(model, parameterizedType);
    } catch (Exception ignored) { }

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

示例12: simpleGenericGenericObject

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleGenericGenericObject() {
    String json = "{\"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\",\"test_t\":{\"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\",\"test_t\":\"generic string!\"}}";

    String reserialized = null;
    try {
        ParameterizedType<SimpleGenericModel<SimpleGenericModel<String>>> parameterizedType = new ParameterizedType<SimpleGenericModel<SimpleGenericModel<String>>>() { };
        SimpleGenericModel<SimpleGenericModel<String>> simpleModel = LoganSquare.parse(json, parameterizedType);
        reserialized = LoganSquare.serialize(simpleModel, parameterizedType);
    } catch (Exception ignored) { }

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

示例13: twoParamGenericModelObject

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void twoParamGenericModelObject() {
    String json = "{\"t_list\":[\"a\",\"b\"],\"test_k\":1,\"test_t\":\"hello\"}";

    String reserialized = null;
    try {
        ParameterizedType<TwoParamGenericModel<String, Integer>> parameterizedType = new ParameterizedType<TwoParamGenericModel<String, Integer>>() { };
        TwoParamGenericModel<String, Integer> model = LoganSquare.parse(json, parameterizedType);
        reserialized = LoganSquare.serialize(model, parameterizedType);
    } catch (Exception ignored) { }

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

示例14: twoParamGenericWithStringModelObject

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void twoParamGenericWithStringModelObject() {
    String json = "{\"t_list\":[\"a\",\"b\"],\"test_k\":1,\"test_t\":\"hello\"}";

    String reserialized = null;
    try {
        ParameterizedType<TwoParamGenericWithStringModel<Integer>> parameterizedType = new ParameterizedType<TwoParamGenericWithStringModel<Integer>>() { };
        TwoParamGenericWithStringModel<Integer> model = LoganSquare.parse(json, parameterizedType);
        reserialized = LoganSquare.serialize(model, parameterizedType);
    } catch (Exception ignored) { }

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

示例15: simpleObject

import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleObject() {
    String json = "{\"date\":\"2015-02-21T18:45:50.748+0000\",\"object_map\":{\"key2\":2,\"key\":\"value\"},\"primitiveByteArray\":[1,2,3],\"primitiveIntArray\":[1,3,5],\"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\"}";

    String reserialized = null;
    try {
        SimpleModel simpleModel = LoganSquare.parse(json, SimpleModel.class);
        reserialized = LoganSquare.serialize(simpleModel);
    } catch (Exception ignored) { }

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


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