Java Code Examples for javax.json.JsonObject#keySet()

The following examples show how to use javax.json.JsonObject#keySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Command.java    From Doradus with Apache License 2.0 6 votes vote down vote up
private String getQueryInputEntity() {
    JsonObjectBuilder jsonQuery = Json.createObjectBuilder();
    String inputEntityParam = metadataJson.getString(INPUT_ENTITY);
    JsonObject parametersNode = metadataJson.getJsonObject(PARAMETERS);
    if (parametersNode != null) {
        JsonObject paramDetail = parametersNode.getJsonObject(inputEntityParam);
        for (String param: paramDetail.keySet()) {
            Object value = commandParams.get(param);
            if (value!=null) {
                jsonQuery.add(param, value.toString());
            }
        }
        return Json.createObjectBuilder().add(inputEntityParam, jsonQuery).build().toString();
    }
    return null;
}
 
Example 2
Source File: JsonFormatterTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void validateDefault(final JsonObject json, final Collection<String> expectedKeys, final String expectedMessage) {
    final Set<String> remainingKeys = new HashSet<>(json.keySet());

    // Check all the expected keys
    for (String key : expectedKeys) {
        checkNonNull(json, key);
        Assert.assertTrue("Missing key " + key + " from JSON object: " + json, remainingKeys.remove(key));
    }

    // Should have no more remaining keys
    Assert.assertTrue("There are remaining keys that were not validated: " + remainingKeys, remainingKeys.isEmpty());

    Assert.assertEquals("org.jboss.logging.Logger", json.getString("loggerClassName"));
    Assert.assertEquals(LoggingServiceActivator.LOGGER.getName(), json.getString("loggerName"));
    Assert.assertTrue("Invalid level found in " + json.get("level"), isValidLevel(json.getString("level")));
    Assert.assertEquals(expectedMessage, json.getString("message"));
}
 
Example 3
Source File: JsonFormatterTest.java    From jboss-logmanager-ext with Apache License 2.0 6 votes vote down vote up
private static Map<String, String> getMap(final JsonObject json, final Key key) {
    final String name = getKey(key);
    if (json.containsKey(name) && !json.isNull(name)) {
        final Map<String, String> result = new LinkedHashMap<>();
        final JsonObject mdcObject = json.getJsonObject(name);
        for (String k : mdcObject.keySet()) {
            final JsonValue value = mdcObject.get(k);
            if (value.getValueType() == ValueType.STRING) {
                result.put(k, value.toString().replace("\"", ""));
            } else {
                result.put(k, value.toString());
            }
        }
        return result;
    }
    return Collections.emptyMap();
}
 
Example 4
Source File: JSONNamedAssociationState.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
@Override
public String nameOf( EntityReference entityReference )
{
    try
    {
        JsonObject references = getReferences();
        for( String name : references.keySet() )
        {
            if( entityReference.identity().toString().equals( references.getString( name ) ) )
            {
                return name;
            }
        }
        return null;
    }
    catch( JsonException ex )
    {
        throw new EntityStoreException( ex );
    }
}
 
Example 5
Source File: ObviousJsonReader.java    From training with MIT License 6 votes vote down vote up
private static List<Map<String, String>> readJsonAsMap() throws FileNotFoundException {
	List<Map<String, String>> mapList = new ArrayList<>();
	
	try (JsonReader jsonReader = Json.createReader(new BufferedReader(new FileReader("big.json")))) {
		// memory leak happens if reading & testing from the same methods
		JsonArray array = jsonReader.readArray();
		for (JsonValue jsonValue : array) {
			JsonObject object= (JsonObject) jsonValue;
			Map<String, String> map = new HashMap<>();
			for (String key: object.keySet()) {
				map.put(key.intern(), object.getString(key));
			}
			mapList.add(map);
		}
	}
	return mapList;
}
 
Example 6
Source File: Command.java    From Doradus with Apache License 2.0 5 votes vote down vote up
/**
 * Finds out if a command is supported by Doradus
 * @param commandsJson
 * @param commandName
 * @param storageService
 * @return
 */
public static JsonObject matchCommand(JsonObject commandsJson, String commandName, String storageService) {
    for (String key : commandsJson.keySet())  {
        if (key.equals(storageService)) {
            JsonObject commandCats = commandsJson.getJsonObject(key);
            if (commandCats.containsKey(commandName)) {
                return commandCats.getJsonObject(commandName);
            }                
        }
    }
    return null;
}
 
Example 7
Source File: TestJson2Xml.java    From iaf with Apache License 2.0 5 votes vote down vote up
public void testStrings(String xmlIn, String jsonIn, URL schemaUrl, String targetNamespace, String rootElement, boolean compactInput, boolean potentialCompactionProblems, boolean checkRoundTrip, String expectedFailureReason) throws Exception {
		System.out.println("schemaUrl ["+schemaUrl+"]");
		if (StringUtils.isNotEmpty(xmlIn)) assertTrue("Expected XML is not valid to XSD",Utils.validate(schemaUrl, xmlIn));

		JsonStructure json = Utils.string2Json(jsonIn);
		System.out.println("jsonIn ["+json+"]");
    	Map<String,Object> overrideMap = new HashMap<String,Object>();
    	overrideMap.put("Key not expected", "value of unexpected key");
    	if (json instanceof JsonObject) {
    		JsonObject jo = (JsonObject)json;
    		for (String key:jo.keySet()) {
    			if (overrideMap.containsKey(key)) {
    				System.out.println("multiple occurrences in object for element ["+key+"]");
    			}
    			overrideMap.put(key, null);
    		}
    	}
    	testJson(jsonIn, null,        false, schemaUrl, targetNamespace, rootElement, compactInput, false, checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], relaxed");
    	testJson(jsonIn, null,        false, schemaUrl, targetNamespace, rootElement, compactInput, true,  checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], strict");
    	testJson(jsonIn, overrideMap, false, schemaUrl, targetNamespace, rootElement, compactInput, false, checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], relaxed, parameters");
    	testJson(jsonIn, overrideMap, false, schemaUrl, targetNamespace, rootElement, compactInput, true,  checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], strict, parameters");
//    	testJson(jsonIn, null,        true, schemaUrl, targetNamespace, rootElement, compactInput, false, checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], relaxed, deep search");
//    	testJson(jsonIn, overrideMap, true, schemaUrl, targetNamespace, rootElement, compactInput, false, checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], relaxed, parameters");
//    	testJson(jsonIn, null,        true, schemaUrl, targetNamespace, rootElement, compactInput, true, checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], strict, deep search");
//    	testJson(jsonIn, overrideMap, true, schemaUrl, targetNamespace, rootElement, compactInput, true, checkRoundTrip?jsonIn:null,expectedFailureReason,"(compact in and conversion) ["+compactInput+"], strict, parameters");
    	if (expectedFailureReason==null) {
	    	if (potentialCompactionProblems) {
	    		if (compactInput) {
		        	testJsonNoRoundTrip(jsonIn, schemaUrl, targetNamespace, rootElement, !compactInput, false, expectedFailureReason,"compact input, full expected, relaxed, potentialCompactionProblems");
		        	testJson(jsonIn, null, false, schemaUrl, targetNamespace, rootElement, !compactInput, true, checkRoundTrip?jsonIn:null,Json2Xml.MSG_EXPECTED_SINGLE_ELEMENT,"compact input, full expected, strict, potentialCompactionProblems");
	    		} else {
	    			testJsonNoRoundTrip(jsonIn, schemaUrl, targetNamespace, rootElement, !compactInput, false, expectedFailureReason,"full input, compact expected, relaxed, potentialCompactionProblems");
		        	testJson(jsonIn, null, false, schemaUrl, targetNamespace, rootElement, !compactInput, true, checkRoundTrip?jsonIn:null,Json2Xml.MSG_FULL_INPUT_IN_STRICT_COMPACTING_MODE,"full input, compact expected, strict, potentialCompactionProblems");
	    		}
	    	} else {
	        	testJson(jsonIn, null, false, schemaUrl, targetNamespace, rootElement, !compactInput, false, checkRoundTrip?jsonIn:null,expectedFailureReason,"compact in ["+compactInput+"] and conversion not, relaxed, no potentialCompactionProblems");
	        	testJson(jsonIn, null, false, schemaUrl, targetNamespace, rootElement, !compactInput, true, checkRoundTrip?jsonIn:null,expectedFailureReason,"compact in ["+compactInput+"] and conversion not, strict, no potentialCompactionProblems");    		
	    	}
    	}
	}
 
Example 8
Source File: DoradusClient.java    From Doradus with Apache License 2.0 5 votes vote down vote up
/**
 * Retrieve the map of commands keyed by service name
 * @return map of commands 
 */
public Map<String, List<String>> listCommands() {
    Map<String, List<String>> result = new HashMap<String, List<String>>();
    for (String cat : restMetadataJson.keySet())  {
        JsonObject commands = restMetadataJson.getJsonObject(cat);
        List<String> names = new ArrayList<String>();
        for (String commandName: commands.keySet()) {
            names.add(commandName);
        }       
        result.put(cat, names);
    }
    return result;
}
 
Example 9
Source File: Json2Xml.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> getAttributes(XSElementDeclaration elementDeclaration, JsonValue node) throws SAXException {
	if (!readAttributes) {
		return null;
	}
	if (!(node instanceof JsonObject)) {
		if (log.isTraceEnabled()) log.trace("getAttributes() parent node is not a JsonObject, but a ["+node.getClass().getName()+"] isParentOfSingleMultipleOccurringChildElement ["+isParentOfSingleMultipleOccurringChildElement()+"]  value ["+node+"], returning null");				
		return null;
	} 
	JsonObject o = (JsonObject)node;
	if (o.isEmpty()) {
		if (log.isTraceEnabled()) log.trace("getAttributes() no children");
		return null;
	}
	try {
		Map<String, String> result=new HashMap<String,String>();
		for (String key:o.keySet()) {
			if (key.startsWith(attributePrefix)) {
				String attributeName=key.substring(attributePrefix.length());
				String value=getText(elementDeclaration, o.get(key));
				if (log.isTraceEnabled()) log.trace("getAttributes() attribute ["+attributeName+"] = ["+value+"]");
				result.put(attributeName, value);
			}
		}
		return result;
	} catch (JsonException e) {
		throw new SAXException(e);
	}
}
 
Example 10
Source File: JavaxJsonFactories.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
@Override
public JsonObjectBuilder cloneBuilderExclude( JsonObject jsonObject, String... keys )
{
    List<String> excludes = Arrays.asList( keys );
    JsonObjectBuilder builder = builderFactory.createObjectBuilder();
    for( String key : jsonObject.keySet() )
    {
        if( !excludes.contains( key ) )
        {
            builder.add( key, jsonObject.get( key ) );
        }
    }
    return builder;
}
 
Example 11
Source File: JavaxJsonFactories.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
@Override
public JsonObjectBuilder cloneBuilder( JsonObject jsonObject )
{
    JsonObjectBuilder builder = builderFactory.createObjectBuilder();
    for( String key : jsonObject.keySet() )
    {
        builder.add( key, jsonObject.get( key ) );
    }
    return builder;
}
 
Example 12
Source File: NetworkConfig.java    From fabric-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * Get the channel names found.
 *
 * @return A set of the channel names found in the configuration file or empty set if none found.
 */

public Set<String> getChannelNames() {
    Set<String> ret = Collections.emptySet();

    JsonObject channels = getJsonObject(jsonConfig, "channels");
    if (channels != null) {
        final Set<String> channelNames = channels.keySet();
        if (channelNames != null && !channelNames.isEmpty()) {
            ret = new HashSet<>(channelNames);
        }
    }
    return ret;
}
 
Example 13
Source File: UserResource.java    From sample-acmegifts with Eclipse Public License 1.0 5 votes vote down vote up
/** Allow for a JsonObject to be modified */
public JsonObjectBuilder createJsonBuilder(JsonObject source) {
  JsonObjectBuilder builder = Json.createObjectBuilder();
  for (String key : source.keySet()) {
    builder.add(key, source.get(key));
  }
  return builder;
}
 
Example 14
Source File: ReportMerger.java    From KITE with Apache License 2.0 5 votes vote down vote up
private static void fixWrongStatus(String pathToReportFolder) throws IOException {
  File reportFolder = new File(pathToReportFolder);
  File[] subFiles = reportFolder.listFiles();
  for (int index = 0; index < subFiles.length; index++) {
    if (subFiles[index].getName().contains("result.json")) {
      JsonObject result = readJsonFile(subFiles[index].getAbsolutePath());
      JsonObject statusDetail = result.getJsonObject("statusDetails");
      String message = statusDetail.getString("message");
      boolean issue = message.equalsIgnoreCase("The test has passed successfully!")
          && !result.getString("status").equals("PASSED");
      if (issue) {
        JsonArray steps = result.getJsonArray("steps");
        for (int i = 0; i < steps.size(); i++) {
          JsonObject step = (JsonObject)steps.get(i);
          if (!step.getString("status").equals("PASSED")){
            statusDetail = step.getJsonObject("statusDetails");
            break;
          }
        }
        JsonObjectBuilder builder = Json.createObjectBuilder();
        for (String key: result.keySet()) {
          if (!key.equals("statusDetails")) {
            builder.add(key, result.get(key));
          } else {
            builder.add(key, statusDetail);
          }
        }
        FileUtils.forceDelete(new File(subFiles[index].getAbsolutePath()));
        printJsonTofile(builder.build().toString(), subFiles[index].getAbsolutePath());
      }
    }
  }
}
 
Example 15
Source File: Json2Xml.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public void startParse(JsonValue node) throws SAXException {
	if (node instanceof JsonObject) {
		JsonObject root = (JsonObject)node;
		if (StringUtils.isEmpty(getRootElement())) {
			if (root.isEmpty()) {
				throw new SAXException("no names found");
			}
			if (root.size()>1) {
				String namesList=null;
				int i=0;
				for (String name:root.keySet()) {
					if (namesList==null) {
						namesList=name;
					} else {
						namesList+=","+name;
					}
					if (i++>5) {
						namesList+=", ...";
						break;
					}
				}
				throw new SAXException("too many names ["+namesList+"]");
			}
			setRootElement((String)root.keySet().toArray()[0]);
		} 
		// determine somewhat heuristically whether the json contains a 'root' node:
		// if the outermost JsonObject contains only one key, that has the name of the root element, 
		// then we'll assume that that is the root element...
		if (root.size()==1 && getRootElement().equals(root.keySet().toArray()[0])) {
			node=root.get(getRootElement());
		}
	}
	if (node instanceof JsonArray && !insertElementContainerElements && strictSyntax) {
		throw new SAXException(MSG_EXPECTED_SINGLE_ELEMENT+" ["+getRootElement()+"] or array element container");
	}
	super.startParse(node);
}
 
Example 16
Source File: FHIRUtil.java    From FHIR with Apache License 2.0 5 votes vote down vote up
public static JsonObjectBuilder toJsonObjectBuilder(JsonObject jsonObject) {
    JsonObjectBuilder builder = BUILDER_FACTORY.createObjectBuilder();
    // JsonObject is a Map<String, JsonValue>
    for (String key : jsonObject.keySet()) {
        JsonValue value = jsonObject.get(key);
        builder.add(key, value);
    }
    return builder;
}
 
Example 17
Source File: JsonSupport.java    From FHIR with Apache License 2.0 5 votes vote down vote up
public static void checkForUnrecognizedElements(Class<?> type, JsonObject jsonObject) {
    Set<java.lang.String> elementNames = JsonSupport.getElementNames(type);
    for (java.lang.String key : jsonObject.keySet()) {
        if (!elementNames.contains(key) && !"resourceType".equals(key) && !"fhir_comments".equals(key)) {
            throw new IllegalArgumentException("Unrecognized element: '" + key + "'");
        }
    }
}
 
Example 18
Source File: SolrEntityIndexerMixin.java    From attic-polygene-java with Apache License 2.0 4 votes vote down vote up
private void indexJson( SolrInputDocument input, Object object )
{
    if( object instanceof JsonArray )
    {
        JsonArray array = (JsonArray) object;
        for( int i = 0; i < array.size(); i++ )
        {
            indexJson( input, array.get( i ) );
        }
    }
    else
    {
        JsonObject jsonObject = (JsonObject) object;
        for( String name : jsonObject.keySet() )
        {
            JsonValue jsonValue = jsonObject.get( name );
            if( jsonValue.getValueType() == JsonValue.ValueType.OBJECT
                || jsonValue.getValueType() == JsonValue.ValueType.ARRAY )
            {
                indexJson( input, jsonValue );
            }
            else
            {
                SchemaField field = indexedFields.get( name );
                if( field != null )
                {
                    Object value;
                    switch( jsonValue.getValueType() )
                    {
                        case NULL:
                            value = null;
                            break;
                        case STRING:
                            value = ( (JsonString) jsonValue ).getString();
                            break;
                        case NUMBER:
                            JsonNumber jsonNumber = (JsonNumber) jsonValue;
                            value = jsonNumber.isIntegral() ? jsonNumber.longValue() : jsonNumber.doubleValue();
                            break;
                        case TRUE:
                            value = Boolean.TRUE;
                            break;
                        case FALSE:
                            value = Boolean.FALSE;
                            break;
                        default:
                            value = jsonValue.toString();
                    }
                    input.addField( name, value );
                }
            }
        }
    }
}
 
Example 19
Source File: ActiveMQServerControlImpl.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
public String listPreparedTransactionDetailsAsHTML(TransactionDetailFactory factory) throws Exception {
   if (AuditLogger.isEnabled()) {
      AuditLogger.listPreparedTransactionDetailsAsHTML(this.server, factory);
   }
   checkStarted();

   clearIO();
   try {
      Map<Xid, Long> xids = resourceManager.getPreparedTransactionsWithCreationTime();
      if (xids == null || xids.size() == 0) {
         return "<h3>*** Prepared Transaction Details ***</h3><p>No entry.</p>";
      }

      ArrayList<Entry<Xid, Long>> xidsSortedByCreationTime = new ArrayList<>(xids.entrySet());
      Collections.sort(xidsSortedByCreationTime, new Comparator<Entry<Xid, Long>>() {
         @Override
         public int compare(final Entry<Xid, Long> entry1, final Entry<Xid, Long> entry2) {
            // sort by creation time, oldest first
            return entry1.getValue().compareTo(entry2.getValue());
         }
      });

      StringBuilder html = new StringBuilder();
      html.append("<h3>*** Prepared Transaction Details ***</h3>");

      for (Map.Entry<Xid, Long> entry : xidsSortedByCreationTime) {
         Xid xid = entry.getKey();

         Transaction tx = resourceManager.getTransaction(xid);

         if (tx == null) {
            continue;
         }

         TransactionDetail detail = factory.createTransactionDetail(xid, tx, entry.getValue());

         JsonObject txJson = detail.toJSON();

         html.append("<table border=\"1\">");
         html.append("<tr><th>creation_time</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_CREATION_TIME) + "</td>");
         html.append("<th>xid_as_base_64</th>");
         html.append("<td colspan=\"3\">" + txJson.get(TransactionDetail.KEY_XID_AS_BASE64) + "</td></tr>");
         html.append("<tr><th>xid_format_id</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_XID_FORMAT_ID) + "</td>");
         html.append("<th>xid_global_txid</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_XID_GLOBAL_TXID) + "</td>");
         html.append("<th>xid_branch_qual</th>");
         html.append("<td>" + txJson.get(TransactionDetail.KEY_XID_BRANCH_QUAL) + "</td></tr>");

         html.append("<tr><th colspan=\"6\">Message List</th></tr>");
         html.append("<tr><td colspan=\"6\">");
         html.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">");

         JsonArray msgs = txJson.getJsonArray(TransactionDetail.KEY_TX_RELATED_MESSAGES);
         for (int i = 0; i < msgs.size(); i++) {
            JsonObject msgJson = msgs.getJsonObject(i);
            JsonObject props = msgJson.getJsonObject(TransactionDetail.KEY_MSG_PROPERTIES);
            StringBuilder propstr = new StringBuilder();
            Set<String> keys = props.keySet();
            for (String key : keys) {
               propstr.append(key);
               propstr.append("=");
               propstr.append(props.get(key));
               propstr.append(", ");
            }

            html.append("<th>operation_type</th>");
            html.append("<td>" + msgJson.get(TransactionDetail.KEY_MSG_OP_TYPE) + "</th>");
            html.append("<th>message_type</th>");
            html.append("<td>" + msgJson.get(TransactionDetail.KEY_MSG_TYPE) + "</td></tr>");
            html.append("<tr><th>properties</th>");
            html.append("<td colspan=\"3\">" + propstr.toString() + "</td></tr>");
         }
         html.append("</table></td></tr>");
         html.append("</table><br>");
      }

      return html.toString();
   } finally {
      blockOnIO();
   }
}
 
Example 20
Source File: LibertyRestEndpoint.java    From microservices-traffic-management-using-istio with Apache License 2.0 4 votes vote down vote up
private JsonObject getRatings(Cookie user, String xreq, String xtraceid, String xspanid,
                              String xparentspanid, String xsampled, String xflags, String xotspan){
  ClientBuilder cb = ClientBuilder.newBuilder();
  String timeout = star_color.equals("black") ? "10000" : "2500";
  cb.property("com.ibm.ws.jaxrs.client.connection.timeout", timeout);
  cb.property("com.ibm.ws.jaxrs.client.receive.timeout", timeout);
  Client client = cb.build();
  WebTarget ratingsTarget = client.target(ratings_service);
  Invocation.Builder builder = ratingsTarget.request(MediaType.APPLICATION_JSON);
  if(xreq!=null) {
    builder.header("x-request-id",xreq);
  }
  if(xtraceid!=null) {
    builder.header("x-b3-traceid",xtraceid);
  }
  if(xspanid!=null) {
    builder.header("x-b3-spanid",xspanid);
  }
  if(xparentspanid!=null) {
    builder.header("x-b3-parentspanid",xparentspanid);
  }
  if(xsampled!=null) {
    builder.header("x-b3-sampled",xsampled);
  }
  if(xflags!=null) {
    builder.header("x-b3-flags",xflags);
  }
  if(xotspan!=null) {
    builder.header("x-ot-span-context",xotspan);
  }
  if(user!=null) {
    builder.cookie(user);
  }
  Response r = builder.get();
  int statusCode = r.getStatusInfo().getStatusCode();
  if (statusCode == Response.Status.OK.getStatusCode() ) {
    StringReader stringReader = new StringReader(r.readEntity(String.class));
    try (JsonReader jsonReader = Json.createReader(stringReader)) {
       JsonObject j = jsonReader.readObject();
       JsonObjectBuilder jb = Json.createObjectBuilder();
       for(String key : j.keySet()){
         int count = j.getInt(key);
         String stars = "<font color=\""+ star_color +"\">";
         for(int i=0; i<count; i++){
           stars += "<span class=\"glyphicon glyphicon-star\"></span>";
         }
         stars += "</font>";
         if(count<5){
           for(int i=0; i<(5-count); i++){
             stars += "<span class=\"glyphicon glyphicon-star-empty\"></span>";
           }
         }
         jb.add(key,stars);
       }
       JsonObject result = jb.build();
       return result;
    }
  }else{
    System.out.println("Error: unable to contact "+ratings_service+" got status of "+statusCode);
    return null;
  }
}