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


Java StringMap.get方法代码示例

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


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

示例1: main

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet("https://www.kimonolabs.com/api/43h8bb74?apikey=a506e75ca96092b0f73b0ff59c15abe6");
    HttpResponse response = client.execute(request);

    LOGGER.info("Response code [{}]", response.getStatusLine().getStatusCode());

    String responseContent = IOUtils.toString(response.getEntity().getContent());
    final KimonoIsbn kimonoIsbn = new Gson().fromJson(responseContent, KimonoIsbn.class);
    LOGGER.info(kimonoIsbn.toString());

    final List<StringMap> books = kimonoIsbn.getResults().get("books");
    for (StringMap book : books) {
        final String isbnUrl = (String) book.get("isbn");
        LOGGER.info(isbnUrl);
        send(isbnUrl);
    }
}
 
开发者ID:adelolmo,项目名称:biblio,代码行数:19,代码来源:BulkBookLoad.java

示例2: testToJsonBinaryProperty

import com.google.gson.internal.StringMap; //导入方法依赖的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();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "eq", null);

  StringMap<Object> left = (StringMap<Object>) jsonMap.get(LEFT);
  checkProperty(left, null, "a");

  StringMap<Object> right = (StringMap<Object>) jsonMap.get(RIGHT);
  checkProperty(right, null, "b");
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:17,代码来源:FilterToJsonTest.java

示例3: testToJsonBinaryLiteral

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryLiteral() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "'a' eq 'b'");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "eq", "Edm.Boolean");

  StringMap<Object> left = (StringMap<Object>) jsonMap.get(LEFT);
  checkLiteral(left, "Edm.String", "a");

  StringMap<Object> right = (StringMap<Object>) jsonMap.get(RIGHT);
  checkLiteral(right, "Edm.String", "b");
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:17,代码来源:FilterToJsonTest.java

示例4: testToJsonMember

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testToJsonMember() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "Location/Country");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMember(jsonMap, null);

  StringMap<Object> source = (StringMap<Object>) jsonMap.get(SOURCE);
  checkProperty(source, null, "Location");

  StringMap<Object> path = (StringMap<Object>) jsonMap.get(PATH);
  checkProperty(path, null, "Country");
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:17,代码来源:FilterToJsonTest.java

示例5: testToJsonMember2

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testToJsonMember2() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "Location/Country/PostalCode");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMember(jsonMap, null);

  StringMap<Object> source1 = (StringMap<Object>) jsonMap.get(SOURCE);
  checkMember(source1, null);

  StringMap<Object> source2 = (StringMap<Object>) source1.get(SOURCE);
  checkProperty(source2, null, "Location");

  StringMap<Object> path1 = (StringMap<Object>) source1.get(PATH);
  checkProperty(path1, null, "Country");

  StringMap<Object> path = (StringMap<Object>) jsonMap.get(PATH);
  checkProperty(path, null, "PostalCode");
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:23,代码来源:FilterToJsonTest.java

示例6: createThreeLevelsDeepInsert

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@Test
public void createThreeLevelsDeepInsert() throws Exception {
  String content = "{\"Name\" : \"Room 2\",\"nr_Building\" : {\"Name\" : \"Building 2\",\"nb_Rooms\" : {\"results\" : [{"
      + "\"nr_Employees\" : {\"__deferred\" : {\"uri\" : \"" + getEndpoint() + "Rooms('1')/nr_Employees\""
      + "}},\"nr_Building\" : {\"__deferred\" : {\"uri\" : \"" + getEndpoint() + "/Rooms('1')/nr_Building\""
      + "}}}]}}}";

  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);

  //Check inline building
  StringMap<?> map = getStringMap(body);
  map = (StringMap<?>) map.get("nr_Building");
  assertNotNull(map);
  assertEquals("Building 2", map.get("Name"));

  //Check inline rooms of the inline building
  map = (StringMap<?>) map.get("nb_Rooms");
  assertNotNull(map);

  ArrayList<?> results = (ArrayList<?>) map.get("results");
  assertNotNull(results);
  assertEquals(2, results.size());
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:27,代码来源:EntryJsonCreateInlineTest.java

示例7: createEntryRoomWithInlineEmptyFeedArray

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@Test
public void createEntryRoomWithInlineEmptyFeedArray() 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\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":[],"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);
  checkEtag(response, "W/\"2\"");

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:25,代码来源:EntryJsonCreateInlineTest.java

示例8: createEntryRoomWithInlineEmptyFeedObject

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@Test
public void createEntryRoomWithInlineEmptyFeedObject() 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\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"results\":[]},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";
  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);
  checkEtag(response, "W/\"2\"");

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:25,代码来源:EntryJsonCreateInlineTest.java

示例9: createEntryRoomWithLink

import com.google.gson.internal.StringMap; //导入方法依赖的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);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));
  @SuppressWarnings("unchecked")
  StringMap<Object> employeesMap = (StringMap<Object>) map.get("nr_Employees");
  assertNotNull(employeesMap);
  @SuppressWarnings("unchecked")
  StringMap<String> deferredMap = (StringMap<String>) employeesMap.get("__deferred");
  assertNotNull(deferredMap);
  assertEquals(getEndpoint() + "Rooms('104')/nr_Employees", deferredMap.get("uri"));
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:25,代码来源:EntryJsonCreateTest.java

示例10: stringMapToHashMap

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
public static HashMap<String, Object> stringMapToHashMap(StringMap<?> stringMap) {
    HashMap<String, Object> res = new HashMap<String, Object>();
    for (String key : stringMap.keySet()) {
        Object value = stringMap.get(key);
        if (StringMap.class.isInstance(value)) {
            HashMap<String, Object> newValue = stringMapToHashMap((StringMap<?>) value);
            res.put(key, newValue);
        } else {
            res.put(key, value);
        }
    }
    return res;
}
 
开发者ID:ldsddn,项目名称:wordpress_app_android,代码行数:14,代码来源:TestUtils.java

示例11: testToJsonBinaryAdd

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testToJsonBinaryAdd() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "1d add 2d add 3d add 4d");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkBinary(jsonMap, "add", "Edm.Double");

  StringMap<Object> left1 = (StringMap<Object>) jsonMap.get(LEFT);
  checkBinary(left1, "add", "Edm.Double");

  StringMap<Object> left2 = (StringMap<Object>) left1.get(LEFT);
  checkBinary(left2, "add", "Edm.Double");

  StringMap<Object> literal1 = (StringMap<Object>) left2.get(LEFT);
  checkLiteral(literal1, "Edm.Double", "1");

  StringMap<Object> literal2 = (StringMap<Object>) left2.get(RIGHT);
  checkLiteral(literal2, "Edm.Double", "2");

  StringMap<Object> literal3 = (StringMap<Object>) left1.get(RIGHT);
  checkLiteral(literal3, "Edm.Double", "3");

  StringMap<Object> right1 = (StringMap<Object>) jsonMap.get(RIGHT);
  checkLiteral(right1, "Edm.Double", "4");
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:29,代码来源:FilterToJsonTest.java

示例12: testToJsonMethod

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testToJsonMethod() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "concat('aa','b')");
  String jsonString = toJson(expression);
  Gson gsonConverter = new Gson();

  StringMap<Object> jsonMap = gsonConverter.fromJson(jsonString, StringMap.class);
  checkMethod(jsonMap, MethodOperator.CONCAT, "Edm.String");

  List<Object> parameter = (List<Object>) jsonMap.get(PARAMETERS);
  checkLiteral((StringMap<Object>) parameter.get(0), "Edm.String", "aa");
  checkLiteral((StringMap<Object>) parameter.get(1), "Edm.String", "b");
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:15,代码来源:FilterToJsonTest.java

示例13: testToJsonUnary

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testToJsonUnary() throws Exception {
  FilterExpression expression = UriParser.parseFilter(null, null, "not 'a'");
  String jsonString = toJson(expression);

  StringMap<Object> jsonMap = new Gson().fromJson(jsonString, StringMap.class);
  checkUnary(jsonMap, UnaryOperator.NOT, null);

  StringMap<Object> operand = (StringMap<Object>) jsonMap.get(OPERAND);
  checkLiteral(operand, "Edm.String", "a");
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:13,代码来源:FilterToJsonTest.java

示例14: getStringMap

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
public StringMap<?> getStringMap(final String body) {
  Gson gson = new Gson();
  final StringMap<?> map = gson.fromJson(body, new TypeToken<StringMap<?>>() {}.getType());
  if (map.get("d") instanceof StringMap<?>) {
    return (StringMap<?>) map.get("d");
  } else {
    return map;
  }
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:10,代码来源:AbstractRefJsonTest.java

示例15: createEntryRoomWithInlineFeedEmployee

import com.google.gson.internal.StringMap; //导入方法依赖的package包/类
@Test
public void createEntryRoomWithInlineFeedEmployee() 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\",\"Seats\":4,\"Version\":2,"
      + "\"nr_Employees\":{\"results\":[{"
      + "\"__metadata\":{"
      + "\"id\":\"" + getEndpoint() + "Employees('1')\","
      + "\"type\":\"RefScenario.Employee\","
      + "\"content_type\":\"image/jpeg\","
      + "\"media_src\":\"" + getEndpoint() + "Employees('1')/$value\","
      + "\"edit_media\":\"" + getEndpoint() + "Employees('1')/$value\"},"
      + " \"EmployeeName\": \"Walter Winter\","
      + "\"ManagerId\": \"1\","
      + "\"RoomId\": \"1\","
      + "\"TeamId\": \"1\","
      + "\"Age\": 52,"
      + "\"Location\":{\"City\":{\"PostalCode\":\"69124\",\"CityName\":\"Heidelberg\"},"
      + "              \"Country\":\"Germany\"},"
      + "\"ImageUrl\": \"" + getEndpoint() + "Employees('1')/$value\"}]},"
      + "\"nr_Building\":{\"__deferred\":{\"uri\":\"" + getEndpoint() + "Rooms('1')/nr_Building\"}}}}";

  HttpResponse response = postUri("Rooms", content, HttpContentType.APPLICATION_JSON, HttpHeaders.ACCEPT, HttpContentType.APPLICATION_JSON, HttpStatusCodes.CREATED);
  checkMediaType(response, HttpContentType.APPLICATION_JSON);

  String body = getBody(response);
  StringMap<?> map = getStringMap(body);
  assertEquals("104", map.get("Id"));
  assertEquals("Room 104", map.get("Name"));

  @SuppressWarnings("unchecked")
  StringMap<String> metadataMap = (StringMap<String>) map.get("__metadata");
  assertNotNull(metadataMap);
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("id"));
  assertEquals("RefScenario.Room", metadataMap.get("type"));
  assertEquals(getEndpoint() + "Rooms('104')", metadataMap.get("uri"));
}
 
开发者ID:SAP,项目名称:cloud-odata-java,代码行数:39,代码来源:EntryJsonCreateInlineTest.java


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