本文整理汇总了Java中com.bluelinelabs.logansquare.LoganSquare.parseList方法的典型用法代码示例。如果您正苦于以下问题:Java LoganSquare.parseList方法的具体用法?Java LoganSquare.parseList怎么用?Java LoganSquare.parseList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bluelinelabs.logansquare.LoganSquare
的用法示例。
在下文中一共展示了LoganSquare.parseList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleObjectListWithNulls
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleObjectListWithNulls() {
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\"}," +
"{\"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\"}," +
"{\"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}," +
"null," +
"null]";
String reserialized = null;
try {
List<SimpleModel> simpleModels = LoganSquare.parseList(json, SimpleModel.class);
reserialized = LoganSquare.serialize(simpleModels, SimpleModel.class);
} catch (Exception ignored) { }
ASSERT.that(json.equals(reserialized)).isTrue();
}
示例2: 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;
}
示例3: onMessage
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Override
public void onMessage(ResponseBody message) throws IOException {
final String json = message.string();
List<Response> responseList = LoganSquare.parseList(json, Response.class);
if (responseList != null) {
for (Response response : responseList) {
Advice advice = response.getAdvice();
if (advice != null) {
faye.handleAdvice(advice);
}
final String channel = response.getChannel(), id = response.getId();
Callback<String> callback = messageCallbacks.get(channel);
if (callback != null) {
callback.callback(response.getData());
}
SendResultHandler<?> handler = resultHandlers.remove(id);
if (handler != null) {
handler.call(json);
}
}
}
reschedulePing();
}
示例4: test_Parse_JSONArrayRepo_ParsesRepoAsArrayDTO
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Frutilla(
Given = "Multiple GitHub repos 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_JSONArrayRepo_ParsesRepoAsArrayDTO() throws IOException {
String lsRepoDataAsArray;
Given:
{
lsRepoDataAsArray = mLocalifyClient.localify().loadRawFile(R.raw.repos_octocat);
}
List<DTORepo> lloRepoAsArrayDTO;
When:
{
lloRepoAsArrayDTO = LoganSquare.parseList(lsRepoDataAsArray, DTORepo.class);
}
Then:
{
assertThat(lloRepoAsArrayDTO).hasSize(1);
assertThat(lloRepoAsArrayDTO.get(0).name).isEqualTo("git-consortium");
}
}
示例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);
}
}
示例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);
}
}
示例7: 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);
}
}
示例8: stringList
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void stringList() {
String json = "[\"test1\",\"test2\",\"test3\",\"test4\"]";
String reserialized = null;
try {
List<String> list = LoganSquare.parseList(json, String.class);
reserialized = LoganSquare.serialize(list, String.class);
} catch (Exception ignored) { }
ASSERT.that(json.equals(reserialized)).isTrue();
}
示例9: intList
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void intList() {
String json = "[1,2,3,4,5,6]";
String reserialized = null;
try {
List<Integer> list = LoganSquare.parseList(json, Integer.class);
reserialized = LoganSquare.serialize(list, Integer.class);
} catch (Exception ignored) { }
ASSERT.that(json.equals(reserialized)).isTrue();
}
示例10: floatList
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void floatList() {
String json = "[1.4,2.0,3.0,4.0,5.03,6.2]";
String reserialized = null;
try {
List<Float> list = LoganSquare.parseList(json, Float.class);
reserialized = LoganSquare.serialize(list, Float.class);
} catch (Exception ignored) { }
ASSERT.that(json.equals(reserialized)).isTrue();
}
示例11: booleanList
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void booleanList() {
String json = "[true,false,false,false,true]";
String reserialized = null;
try {
List<Boolean> list = LoganSquare.parseList(json, Boolean.class);
reserialized = LoganSquare.serialize(list, Boolean.class);
} catch (Exception ignored) { }
ASSERT.that(json.equals(reserialized)).isTrue();
}
示例12: mixedObjectList
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void mixedObjectList() {
String json = "[true,1,1.0,\"test1\",false,1000,1000000000,\"test2\",{\"subkey1\":1,\"subkey2\":\"string\"},[1,2,3]]";
String reserialized = null;
try {
List<Object> list = LoganSquare.parseList(json, Object.class);
reserialized = LoganSquare.serialize(list, Object.class);
} catch (Exception ignored) { }
ASSERT.that(json.equals(reserialized)).isTrue();
}
示例13: simpleObjectList
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
@Test
public void simpleObjectList() {
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\"}," +
"{\"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 {
List<SimpleModel> simpleModels = LoganSquare.parseList(json, SimpleModel.class);
reserialized = LoganSquare.serialize(simpleModels, SimpleModel.class);
} catch (Exception ignored) { }
ASSERT.that(json.equals(reserialized)).isTrue();
}
示例14: call
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
void call(String json) {
if (callback == null || json == null) return;
try {
for (T item : LoganSquare.parseList(json, cls)) {
if (id != null && !id.equals(item.getId())) continue;
callback.callback(item);
}
} catch (IOException e) {
// TODO handle this
}
}
示例15: handleParsing
import com.bluelinelabs.logansquare.LoganSquare; //导入方法依赖的package包/类
public void handleParsing() {
try {
final List<YouTubeVideo> youTubeVideos = LoganSquare.parseList(JSON_TO_PARSE, YouTubeVideo.class);
String parsedList = "";
for (YouTubeVideo video : youTubeVideos) {
Log.d(TAG, "[Object.Parsed]:" + video.toString());
parsedList += video.toString();
}
resultTextView.setText(parsedList);
} catch (IOException e) {
e.printStackTrace();
}
}