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


Java JSONObject.get方法代码示例

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


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

示例1: PIBeacon

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
public PIBeacon(JSONObject beaconObj) {
    JSONObject geometry = (JSONObject)beaconObj.get("geometry");
    JSONObject properties = (JSONObject)beaconObj.get("properties");

    code = (String) properties.get(JSON_CODE);
    name = (String) properties.get(JSON_NAME);
    description = properties.get(JSON_DESCRIPTION) != null ? (String)properties.get(JSON_DESCRIPTION) : "";
    proximityUUID = (String) properties.get(JSON_PROXIMITY_UUID);
    major = (String) properties.get(JSON_MAJOR);
    minor = (String) properties.get(JSON_MINOR);
    threshold = objToDouble(properties.get(JSON_THRESHOLD));

    JSONArray coordinates = (JSONArray) geometry.get("coordinates");
    x = objToDouble(coordinates.get(0));
    y = objToDouble(coordinates.get(1));

}
 
开发者ID:presence-insights,项目名称:pi-clientsdk-android,代码行数:18,代码来源:PIBeacon.java

示例2: Scene

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
private Scene(
	JSONObject jObj
   ) {
       if( jObj == null ) return;
       
	Object value = jObj.get( KEY_NAME );
	if( value != null &&  value instanceof String )
	{
		_name = (String)value;
	}
   	
	value = jObj.get( KEY_GUID );
	if( value != null &&  value instanceof String )
	{
		_guid = (String)value;
	}
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:18,代码来源:ResultViewableMetadata.java

示例3: formatTree

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
private static void formatTree(JSONObject node, int level, List<Map<String,String>> arr) {	
	if (node == null) return;
	JSONArray children = (JSONArray)node.get("children");
	if (level > 0 && (children == null || level != 2)) {
		Map<String,String> obj = new HashMap<String,String>();
		obj.put("id", (String)node.get("id"));
		if (children != null) obj.put("title", "true");
		if (node.containsKey("percentage")) {
			double p = (Double)node.get("percentage");
			p = Math.floor(p * 100.0);
			obj.put("value", Double.toString(p) + "%");
		}
		arr.add(obj);
	}
	if (children != null && !"sbh".equals(node.get("id"))) {
		for (int i = 0; i < children.size(); i++) {
			formatTree((JSONObject)children.get(i), level + 1, arr);
		}
	}
	
}
 
开发者ID:IBM-Cloud,项目名称:talent-manager,代码行数:22,代码来源:WatsonUserModeller.java

示例4: readHostnameFromVcapEnvironment

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
private static String readHostnameFromVcapEnvironment() {
	String vcapApplication = System.getenv().get("VCAP_APPLICATION");
	if (vcapApplication != null) {
		try {
			JSONObject p = (JSONObject) JSON.parse(vcapApplication);
			JSONArray uris = (JSONArray) p.get("application_uris");
			// Take the first uri
			if (uris != null) {
				return (String) uris.iterator().next();
			}
		} catch (IOException e) {
			// Let's log and ignore this case and drop through to the
			// default case
			e.printStackTrace();
		}
	}

	return null;
}
 
开发者ID:WASdev,项目名称:sample.consulservicediscovery,代码行数:20,代码来源:Endpoint.java

示例5: addToJson

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
/**
 * Helper method to add the device info to an existing JSON Object
 *
 * @param payload an existing JSON Object
 * @return JSON Object with the device information added
 */
protected JSONObject addToJson(JSONObject payload) {
    // this is to ensure we do not overwrite the device descriptor when we are updating a document
    if (payload.get(JSON_DEVICE_DESCRIPTOR) == null) {
        payload.put(JSON_DEVICE_DESCRIPTOR, mDeviceDescriptor);
    }
    if (mName != null) {
        payload.put(JSON_NAME, mName);
    }
    if (mRegistrationType != null) {
        payload.put(JSON_REGISTRATION_TYPE, mRegistrationType);
    }
    if (mData != null) {
        payload.put(JSON_DATA, mData);
    }
    if (mUnencryptedData != null) {
        payload.put(JSON_UNENCRYPTED_DATA, mUnencryptedData);
    }
    payload.put(JSON_REGISTERED, mRegistered);
    payload.put(JSON_BLACKLIST, mBlacklisted);

    return payload;
}
 
开发者ID:presence-insights,项目名称:pi-clientsdk-android,代码行数:29,代码来源:PIDeviceInfo.java

示例6: PIDevice

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
public PIDevice(JSONObject deviceObj) {
    code = (String) deviceObj.get(JSON_CODE);
    descriptor = (String) deviceObj.get(JSON_DESCRIPTOR);
    registered = (Boolean) deviceObj.get(JSON_REGISTERED);

    if (registered) {
        name = (String) deviceObj.get(JSON_NAME);
        descriptorType = (String) deviceObj.get(JSON_DESCRIPTOR_TYPE);
        registrationType = (String) deviceObj.get(JSON_REGISTRATION_TYPE);
        data = (JSONObject) deviceObj.get(JSON_DATA);
        unencryptedData = (JSONObject) deviceObj.get(JSON_UNENCRYPTED_DATA);
        blacklisted = (Boolean) deviceObj.get(JSON_BLACKLIST);
        if (deviceObj.containsKey(JSON_AUTOBLACKLIST)) {
            autoblacklisted = (Boolean) deviceObj.get(JSON_AUTOBLACKLIST);
        }
    }
}
 
开发者ID:presence-insights,项目名称:pi-clientsdk-android,代码行数:18,代码来源:PIDevice.java

示例7: Message

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
/**
 * 
 * @author Doug
 * {
 * 	"code":"Revit-MissingLink",
 * 	"type":"warning",
 * 	"message":
 * 		[
 * 			"<message>Missing link files: <ul>{0}<\/ul><\/message>",
 * 			"NE Corner Building 6.dwg"
 * 		]
 * }
 */
Message(
    JSONObject jObj 
   ) {
	if( jObj != null )
	{
		Object value = jObj.get( KEY_CODE );
		if( value != null && value instanceof String )
		{
			_code = (String)value;
		}

		value = jObj.get( KEY_TYPE );
		if( value != null && value instanceof String )
		{
			_type = (String)value;
		}

		value = jObj.get( KEY_MESSAGE );
        if (value != null  && value instanceof  JSONArray )
        {
        	JSONArray jArray = (JSONArray)value;
        	_messages = new String[ jArray.size() ];

        	@SuppressWarnings( "rawtypes" )
            Iterator itr = jArray.listIterator();
        	int i = 0;
        	while( itr.hasNext() )
        	{
        		value = itr.next();
        		if( value instanceof String )
        		{
        			_messages[i++] = (String)value;
        		}
        	}
        }
	}
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:51,代码来源:Message.java

示例8: Permission

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
Permission(
    JSONObject jObj 
   ) {
	if( jObj != null )
	{
		Object value = jObj.get( KEY_SERVICE_ID );		// V1 API
		if( value != null && value instanceof String )
		{
			_serviceId = (String)value;
		}

		value = jObj.get( KEY_AUTH_ID );				// V2 API
		if( value != null && value instanceof String )
		{
			_serviceId = (String)value;
		}

		value = jObj.get( KEY_ACCESS );
		if( value != null )
		{
			if( value != null && value instanceof String )
			{
				_access = (String)value;
			}
		}
	}
}
 
开发者ID:IBM,项目名称:MaximoForgeViewerPlugin,代码行数:28,代码来源:Permission.java

示例9: parseForRegularExpression

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
/**
  * This method extracts personal data using regular expressions
  *
  * @param text Text document from which text matching regular expressions need to be extracted
  * @param nluJSON NLUOutput
  * @return nluJSON Regular expression parsing results are appended to the input NLU output and returned
  */
public JSONObject parseForRegularExpression(String text, JSONObject nluJSON) {
	// get, from config, what entity types to be used for regular expression
	String regexEntityTypesConfig = System.getenv("regex_params");
	String[] regexEntityTypes = regexEntityTypesConfig.split(",");

	// extract string from text for each regex and build JSONObjects for
	// them
	JSONArray entities = (JSONArray) nluJSON.get("entities");
	if (entities == null) {
		return new JSONObject();
	}
	if (regexEntityTypes != null && regexEntityTypes.length > 0) {
		for (int i = 0; i < regexEntityTypes.length; i++) {
			String regexEntityType = regexEntityTypes[i];
			// Get regular expression got this entity type
			String regex = System.getenv(regexEntityType + "_regex");

			// Now get extracted values from text
			// getting is as a list
			List<String> matchResultList = getRegexMatchingWords(text, regex);

			// Add entries in this regex to entities in nluOutput, for each
			// result
			// First build a JSONObject
			if (matchResultList != null && matchResultList.size() > 0) {
				for (int j = 0; j < matchResultList.size(); j++) {
					String matchResult = matchResultList.get(j);

					JSONObject entityEntry = new JSONObject();
					entityEntry.put("type", regexEntityType);
					entityEntry.put("text", matchResult);
					entities.add(entityEntry);
				}
			}
		}
	}

	return nluJSON;
}
 
开发者ID:IBM,项目名称:gdpr-fingerprint-pii,代码行数:47,代码来源:DataExtractorUsingRegex.java

示例10: calculateConfidence

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
private float calculateConfidence(JSONArray categoriesArray) throws Exception{
	// Get categories in order of priority
	float currentConfidence = 0;
	try{
		String[] configCategories = GDPRConfig.getCategories();
		for( int i = 0; i < configCategories.length; i++ ){ // categories in order of weightage
			String category = configCategories[i];
			// calculate weightage for this category
			for( int j = 0; j < categoriesArray.size(); j++ ){
				JSONObject piiDataCategoryNode = (JSONObject)categoriesArray.get(j);
				JSONArray attributesArray = (JSONArray)piiDataCategoryNode.get(category);
				if( attributesArray != null ){
					// calculate weightage for all PII entries in this node
					for( int k = 0; k < attributesArray.size(); k++ ){
						JSONObject piiNode = (JSONObject)attributesArray.get(k);
						String piiType = piiNode.get("piitype").toString();
						String pii = piiNode.get("pii").toString();
						float weight = ((Float)piiNode.get("weight")).floatValue();
						currentConfidence = getUpdatedConfidence(weight, currentConfidence);
					}
				}
			}
		}
		return currentConfidence/100;

	}catch( Exception e){
		e.printStackTrace();
		throw e;
	}
}
 
开发者ID:IBM,项目名称:gdpr-fingerprint-pii,代码行数:31,代码来源:ConfidenceScorer.java

示例11: getNLUCredentials

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
private Map<String, String> getNLUCredentials() throws Exception{

		Map<String, String> nluCredentialsMap = new HashMap<String, String>();

		try{
			String VCAP_SERVICES = System.getenv("VCAP_SERVICES");
			//String VCAP_SERVICES = "{\"natural-language-understanding\":[{\"credentials\":{\"url\":\"https://gateway.watsonplatform.net/natural-language-understanding/api\",\"username\":\"8ea86c6c-c681-4186-bf91-e766413145ad\",\"password\":\"XaQHFNhhpnKX\"},\"syslog_drain_url\":null,\"volume_mounts\":[],\"label\":\"natural-language-understanding\",\"provider\":null,\"plan\":\"free\",\"name\":\"NLU - GDPR\",\"tags\":[\"watson\",\"ibm_created\",\"ibm_dedicated_public\",\"lite\"]}]}";

			if (VCAP_SERVICES != null) {
				// parse the VCAP JSON structure
				JSONObject obj = (JSONObject) JSONObject.parse(VCAP_SERVICES);
				JSONArray nluArray = (JSONArray)obj.get("natural-language-understanding");
				if( nluArray != null && nluArray.size() > 0 ){
					for( int i = 0; i < nluArray.size(); i++ ){
						JSONObject o = (JSONObject)nluArray.get(i);
						if( o.get("credentials") != null ){
							JSONObject credsObject = (JSONObject)o.get("credentials");
							nluCredentialsMap.put("username", (String)credsObject.get("username"));
							nluCredentialsMap.put("password", (String)credsObject.get("password"));
							nluCredentialsMap.put("nluURL", (String)credsObject.get("url"));
						}
					}
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			throw new Exception(e.getMessage());
		}
		if( nluCredentialsMap.get("username") == null ){
			throw new Exception("NLU Credentials not found");
		}
		return nluCredentialsMap;
	}
 
开发者ID:IBM,项目名称:gdpr-fingerprint-pii,代码行数:34,代码来源:PIIDataExtractor.java

示例12: invoke

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
@Override
public void invoke(Map<Object, Object> requestStateMap, HttpZosConnectRequest httpZosConnectRequest,
		RequestData requestData, ResponseData responseData) throws ServiceException {
	JSONObject requestObj = requestData.getJSON();
	//Check that the service is started, otherwise return 503
	if(status.getStatus().equals(ServiceStatus.STOPPED)){
		throw new ServiceException("Service is stopped", 503);
	} else if(requestObj == null){
		//If the client didn't sent a JSON payload then return an error
		throw new ServiceException("No input payload", 400);
	} else if(requestObj.get("input") == null){
		//If the supplied JSON doesn't contain the required field then return an error
		throw new ServiceException("Invalid JSON", 400);
	} else {
		//Else create the response object
		JSONObject response = new JSONObject();
		String input = requestObj.get("input").toString();
		requestCount.incrementAndGet();
		this.requestData.addAndGet(input.length());
		Date now = new Date();
		response.put("output", input);
		response.put("date", sdf.format(now));
		try {
			responseData.setJSON(response);
		} catch (IOException e) {
			throw new ServiceException();
		}
	}

}
 
开发者ID:zosconnect,项目名称:zosconnect-sample-serviceprovider,代码行数:31,代码来源:SampleServiceProvider.java

示例13: processControlPort

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
protected void processControlPort(StreamingInput<Tuple> stream, Tuple tuple) {
	String jsonString = tuple.getString(0);
	try {
		JSONObject config = JSONObject.parse(jsonString);
		Boolean shouldReloadModel = (Boolean)config.get("reloadModel");
		if(shouldReloadModel) {
			synchronized(model) {
				model = loadModel(javaContext.sc(), modelPath);
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
		tracer.log(TraceLevel.ERROR, "TRACE_M_CONTROL_PORT_ERROR", new Object[]{e.getMessage()});
	}
}
 
开发者ID:IBMStreams,项目名称:streamsx.sparkMLLib,代码行数:16,代码来源:AbstractSparkMLlibOperator.java

示例14: PISite

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
public PISite(JSONObject siteObj) {
    code = (String) siteObj.get(JSON_CODE);
    name = (String) siteObj.get(JSON_NAME);
    timeZone = (String) siteObj.get(JSON_TIMEZONE);

    street = (String) siteObj.get(JSON_STREET);
    city = (String) siteObj.get(JSON_CITY);
    state = (String) siteObj.get(JSON_STATE);
    zip = (String) siteObj.get(JSON_ZIP);
    country = (String) siteObj.get(JSON_COUNTRY);
}
 
开发者ID:presence-insights,项目名称:pi-clientsdk-android,代码行数:12,代码来源:PISite.java

示例15: PISensor

import com.ibm.json.java.JSONObject; //导入方法依赖的package包/类
public PISensor(JSONObject sensorObj) {
    JSONObject geometry = (JSONObject)sensorObj.get("geometry");
    JSONObject properties = (JSONObject)sensorObj.get("properties");

    code = (String) properties.get(JSON_CODE);
    name = (String) properties.get(JSON_NAME);
    description = properties.get(JSON_DESCRIPTION) != null ? (String)properties.get(JSON_DESCRIPTION) : "";
    threshold = objToDouble(properties.get(JSON_THRESHOLD));

    JSONArray coordinates = (JSONArray) geometry.get("coordinates");
    x = objToDouble(coordinates.get(0));
    y = objToDouble(coordinates.get(1));
}
 
开发者ID:presence-insights,项目名称:pi-clientsdk-android,代码行数:14,代码来源:PISensor.java


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