本文整理匯總了Java中com.google.gson.internal.LinkedTreeMap.get方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedTreeMap.get方法的具體用法?Java LinkedTreeMap.get怎麽用?Java LinkedTreeMap.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gson.internal.LinkedTreeMap
的用法示例。
在下文中一共展示了LinkedTreeMap.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAttachmentList
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
private JsonArray getAttachmentList(LinkedTreeMap<String, Object> attachmentList, String docID) {
JsonArray attachmentArray = new JsonArray();
for (Object key : attachmentList.keySet()) {
LinkedTreeMap<String, Object> attach = (LinkedTreeMap<String, Object>) attachmentList.get(key);
JsonObject attachedObject = new JsonObject();
// set the content type of the attachment
attachedObject.addProperty("content_type", attach.get("content_type").toString());
// append the document id and attachment key to the URL
attachedObject.addProperty("url", "attach?id=" + docID + "&key=" + key);
// set the key of the attachment
attachedObject.addProperty("key", key + "");
// add the attachment object to the array
attachmentArray.add(attachedObject);
}
return attachmentArray;
}
示例2: formatListForPopcorn
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
public ArrayList<Media> formatListForPopcorn(ArrayList<Media> existingList) {
for (LinkedTreeMap<String, Object> item : showsList) {
Media media;
if (item.get("type").toString().equalsIgnoreCase("movie")) {
media = new Movie(sMediaProvider, null);
} else {
media = new Show(sMediaProvider, null);
}
media.title = (String) item.get("name");
media.videoId = item.get("id").toString();
media.imdbId = "mal-" + media.videoId;
String year = item.get("aired").toString();
if (year.contains(", ")) {
year = year.split(", ")[1];
}
if (year.contains(" ")) {
year = year.split(" ")[0];
}
media.year = year;
media.image = media.headerImage = item.get("malimg").toString();
existingList.add(media);
}
return existingList;
}
示例3: formatListForPopcorn
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
public ArrayList<Media> formatListForPopcorn(ArrayList<Media> existingList) {
for (LinkedTreeMap<String, Object> item : showsList) {
Show show = new Show(sMediaProvider, sSubsProvider);
show.title = (String) item.get("title");
show.videoId = (String) item.get("imdb_id");
show.seasons = (Integer) item.get("seasons");
show.tvdbId = (String) item.get("tvdb_id");
show.year = (String) item.get("year");
LinkedTreeMap<String, String> images = (LinkedTreeMap<String, String>) item.get("images");
if(!images.get("poster").contains("images/posterholder.png"))
show.image = images.get("poster").replace("/original/", "/medium/");
if(!images.get("poster").contains("images/posterholder.png"))
show.headerImage = images.get("fanart").replace("/original/", "/medium/");
existingList.add(show);
}
return existingList;
}
示例4: requestRoomId
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@SuppressWarnings(value = "unchecked")
private String requestRoomId() throws Exception {
HttpResponse response =
callUri("Rooms", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.OK);
checkMediaType(response, HttpContentType.APPLICATION_JSON);
String body = getBody(response);
LinkedTreeMap<?, ?> map = getLinkedTreeMap(body);
List<LinkedTreeMap<String, String>> results = (List) map.get("results");
for (LinkedTreeMap<String, String> result : results) {
if(result.get("Name").equals("Small green room")) {
return result.get("Id");
}
}
return null;
}
示例5: entitySetRooms
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
@SuppressWarnings(value = "unchecked")
public void entitySetRooms() throws Exception {
HttpResponse response =
callUri("Rooms", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.OK);
checkMediaType(response, HttpContentType.APPLICATION_JSON);
String body = getBody(response);
LinkedTreeMap<?, ?> map = getLinkedTreeMap(body);
List<LinkedTreeMap<String, String>> results = (List) map.get("results");
assertFalse(results.isEmpty());
LinkedTreeMap<String, String> firstRoom = null;
for (LinkedTreeMap<String, String> result: results) {
if(result.get("Name").equals("Small green room")) {
firstRoom = result;
}
}
assertNotNull(firstRoom);
assertEquals("Small green room", firstRoom.get("Name"));
assertEquals(20.0, firstRoom.get("Seats"));
assertEquals(42.0, firstRoom.get("Version"));
}
示例6: entitySetRoomsSkip
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
@SuppressWarnings(value = "unchecked")
public void entitySetRoomsSkip() throws Exception {
HttpResponse response =
callUri("Rooms?$skip=1", HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.OK);
checkMediaType(response, HttpContentType.APPLICATION_JSON);
String body = getBody(response);
LinkedTreeMap<?, ?> map = getLinkedTreeMap(body);
List<LinkedTreeMap<String, String>> results = (List) map.get("results");
assertFalse(results.isEmpty());
//
assertTrue(roomsCount() != results.size());
LinkedTreeMap<String, String> roomToCheck = null;
for (LinkedTreeMap<String, String> result: results) {
if(result.get("Name").equals("Small dark green room")) {
roomToCheck = result;
}
}
assertNotNull(roomToCheck);
assertEquals("Small dark green room", roomToCheck.get("Name"));
assertEquals(30.0, roomToCheck.get("Seats"));
assertEquals(2.0, roomToCheck.get("Version"));
}
示例7: testToJsonBinaryProperty
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryProperty() throws Exception {
FilterExpression expression = UriParser.parseFilter(null, null, "a eq b");
String jsonString = toJson(expression);
Gson gsonConverter = new Gson();
LinkedTreeMap<String, Object> jsonMap = gsonConverter.fromJson(jsonString, LinkedTreeMap.class);
checkBinary(jsonMap, "eq", null);
LinkedTreeMap<String, Object> left = (LinkedTreeMap<String, Object>) jsonMap.get(LEFT);
checkProperty(left, null, "a");
LinkedTreeMap<String, Object> right = (LinkedTreeMap<String, Object>) jsonMap.get(RIGHT);
checkProperty(right, null, "b");
}
示例8: createAnonymousUser
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
public static String createAnonymousUser(String android_ID) throws UnsupportedEncodingException
{
HttpPost request = new HttpPost("https://testservicecenter.yucat.com/servicecenter/api/user/anonymous");
// URI uri = URI.create("https://testserviceCenter.yucat.com/ServiceCenter/api/user/anonymous");
// HttpPost request = new HttpPost("https://testserviceCenter.yucat.com/ServiceCenter/api/account/permission");
request.setHeader("Authorization", CLIENT);
request.setHeader(HTTP.CONTENT_TYPE,"application/json");
Gson gson = new Gson();
String json = gson.toJson(new AnonymousUserCreateInput(android_ID));
Log.i("ServiceCentre", "client = " + CLIENT);
Log.i("ServiceCentre", "input json = " + json);
request.setEntity(new StringEntity(json, "UTF-8"));
String response = executeRequest(request, 3000, 3000);
LinkedTreeMap<String, Double> map = gson.fromJson(response, LinkedTreeMap.class);
if(map == null) return null;
Double userid = map.get("anonymoususerid");
Log.i("ServiceCentre", "parse user id = " + userid);
Log.i("ServiceCentre", "user id to string = " + String.valueOf(userid.intValue()));
return String.valueOf(userid.intValue());
}
示例9: createEntryRoomWithLink
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@Test
public void createEntryRoomWithLink() throws Exception {
String content = "{\"d\":{\"__metadata\":{\"id\":\"" + getEndpoint() + "Rooms('1')\","
+ "\"uri\":\"" + getEndpoint() + "Rooms('1')\",\"type\":\"RefScenario.Room\","
+ "\"etag\":\"W/\\\"3\\\"\"},"
+ "\"Id\":\"1\",\"Name\":\"Room 104\","
+ "\"nr_Employees\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Employees\"}},"
+ "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
assertNotNull(content);
HttpResponse response =
postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT,
HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
checkMediaType(response, HttpContentType.APPLICATION_JSON);
String body = getBody(response);
LinkedTreeMap<?, ?> map = getLinkedTreeMap(body);
assertEquals("104", map.get("Id"));
assertEquals("Room 104", map.get("Name"));
@SuppressWarnings("unchecked")
LinkedTreeMap<String, Object> employeesMap = (LinkedTreeMap<String, Object>) map.get("nr_Employees");
assertNotNull(employeesMap);
@SuppressWarnings("unchecked")
LinkedTreeMap<String, String> deferredMap = (LinkedTreeMap<String, String>) employeesMap.get("__deferred");
assertNotNull(deferredMap);
assertEquals(getEndpoint() + "Rooms('104')/nr_Employees", deferredMap.get("uri"));
}
示例10: parseArrayValue
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@NonNull
public static ArrayValue parseArrayValue(LinkedTreeMap receivedStructure) {
return new ArrayValue(
(ArrayList) receivedStructure.get("array"),
((Double) receivedStructure.get("len")).intValue(),
((Double) receivedStructure.get("offset")).intValue()
);
}
示例11: getToken
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
public static String getToken(String json) {
Response result = new Gson().fromJson(json, Response.class);
LinkedTreeMap content = (LinkedTreeMap) result.getData();
for (Object key : content.keySet()) {
System.out.println(key);
if ("token.TokenTest".equals(key.toString())) {
System.out.println("111");
return (String) content.get(key);
}
}
return null;
}
示例12: getTokenFromJson
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
public static String getTokenFromJson(String json) {
Response result = new Gson().fromJson(json, Response.class);
LinkedTreeMap content = (LinkedTreeMap) result.getData();
for (Object key : content.keySet()) {
if ("token".equals(key.toString())) {
return (String) content.get(key);
}
}
return null;
}
示例13: getValueDate
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
public static ZonedDateTime getValueDate(LinkedTreeMap value){
try {
String type = getPRType(value);
LinkedTreeMap pr = (LinkedTreeMap) value.get(type);
if(pr.containsKey("created_on")){
return ZonedDateTime.parse(pr.get("created_on").toString());
}else{
return ZonedDateTime.parse(pr.get("date").toString());
}
}catch (Exception e){
//Gotcha!
return null;
}
}
示例14: getCodeTemplateForTask
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
private static String getCodeTemplateForTask(@NotNull Language language,
@Nullable LinkedTreeMap codeTemplates) {
if (codeTemplates != null) {
final String languageString = EduPluginConfigurator.INSTANCE.forLanguage(language).getStepikDefaultLanguage();
return (String)codeTemplates.get(languageString);
}
return null;
}
示例15: getZipFromLatLong
import com.google.gson.internal.LinkedTreeMap; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public static String getZipFromLatLong(String latitude, String longitude) {
String request = "https://maps.googleapis.com/maps/api/geocode/json?";
String address = "address=";
String coOrdinates = "latlng=";
CustomUtilities custom = new CustomUtilities();
String zip = "";
String finalRequest = request + coOrdinates + latitude + "," + longitude + "&" + key;
// To convert resulting JSON into Map
Gson gson = new Gson();
// Models expected JSON, very basic
Type type = new TypeToken<Map<String, Object>>() {
}.getType();
// Pulls JSON from api request
String json = custom.RequestToString(finalRequest);
// Creates map using Gson
Map<String, Object> map = gson.fromJson(json, type);
ArrayList list = ((ArrayList)((LinkedTreeMap)((ArrayList) map.get("results")).get(0)).get("address_components"));
for (Object elt : list) {
LinkedTreeMap treeElt = (LinkedTreeMap) elt;
String name = (String) ((ArrayList)treeElt.get("types")).get(0);
if (name.equals("postal_code")) {
zip = (String) (treeElt.get("short_name"));
break;
}
}
return zip == null ? " " : zip;
}