本文整理汇总了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));
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
}
}
}
}
示例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;
}
}
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
}
}
示例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()});
}
}
示例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);
}
示例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));
}