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


Java JSONArray.size方法代码示例

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


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

示例1: formatTree

import com.ibm.json.java.JSONArray; //导入方法依赖的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

示例2: getPolygonsFromJson

import com.ibm.json.java.JSONArray; //导入方法依赖的package包/类
private ArrayList<ArrayList<Point>> getPolygonsFromJson(JSONArray coordinates) {
    ArrayList<ArrayList<Point>> polygons = new ArrayList<ArrayList<Point>>();

    for (int i = 0; i < coordinates.size(); i++) {
        JSONArray polygon = (JSONArray) coordinates.get(i);
        ArrayList<Point> points = new ArrayList<Point>();
        for (int j = 0; j < polygon.size(); j++) {
            JSONArray point = (JSONArray)polygon.get(j);
            points.add(new Point(objToInt(point.get(0)), objToInt(point.get(0))));
        }
        polygons.add(points);
    }

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

示例3: Message

import com.ibm.json.java.JSONArray; //导入方法依赖的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

示例4: calculateConfidence

import com.ibm.json.java.JSONArray; //导入方法依赖的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

示例5: getNLUCredentials

import com.ibm.json.java.JSONArray; //导入方法依赖的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

示例6: PIOrg

import com.ibm.json.java.JSONArray; //导入方法依赖的package包/类
public PIOrg(JSONObject orgObj) {
    code = (String) orgObj.get(JSON_CODE);
    name = (String) orgObj.get(JSON_NAME);
    description = orgObj.get(JSON_DESCRIPTION) != null ? (String)orgObj.get(JSON_DESCRIPTION) : "";

    registrationTypes = new ArrayList<String>();
    JSONArray tempTypes = (JSONArray) orgObj.get(JSON_REGISTRATION_TYPES);

    for (int i = 0; i < tempTypes.size(); i++) {
        registrationTypes.add((String) tempTypes.get(i));
    }
}
 
开发者ID:presence-insights,项目名称:pi-clientsdk-android,代码行数:13,代码来源:PIOrg.java

示例7: getTagsFromJson

import com.ibm.json.java.JSONArray; //导入方法依赖的package包/类
private ArrayList<String> getTagsFromJson(JSONObject properties) {
    ArrayList<String> tags = new ArrayList<String>();
    JSONArray tempTags = (JSONArray) properties.get(JSON_TAGS);

    for (int i = 0; i < tempTags.size(); i++) {
        tags.add((String) tempTags.get(i));
    }

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

示例8: setAssertHelper

import com.ibm.json.java.JSONArray; //导入方法依赖的package包/类
private <T> void setAssertHelper(Set<T> s, JSONArray pya) {
    Set<T> sorteds = new TreeSet<T> (s);
    Set<T> pyset = new TreeSet<T>();
    for (int i = 0; i < pya.size(); i++) {
      @SuppressWarnings("unchecked")
T val = ((T) pya.get(i));
      pyset.add(val);
    }
    for (T si : sorteds) {
      Long sil = ((Number) si).longValue();
      assertEquals(true, pyset.contains(sil));
    }
  }
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:14,代码来源:SubscribeSPLDictTest.java

示例9: BucketDescription

import com.ibm.json.java.JSONArray; //导入方法依赖的package包/类
public BucketDescription(
    JSONObject jObj 
) {
	Object value = jObj.get( KEY_BUCKET_KEY );
	if( value != null &&  value instanceof String )
	{
		_bucketKey = (String)value;
	}
	else
	{
		value = jObj.get( KEY_KEY );
		if( value != null &&  value instanceof String )
		{
			_bucketKey = (String)value;
		}
	}
   	
	value = jObj.get( KEY_OWNER );
	if( value != null &&  value instanceof String )
	{
		_owner = (String)value;
	}
   	
       value = jObj.get( KEY_CREATE_DATE );
       if( value != null && value instanceof Long )
       {
   		_createDate = new Date( (Long)value );
       }

	value = jObj.get( KEY_POLICY_KEY );
	if( value != null &&  value instanceof String )
	{
		_policyKey = (String)value;
	}
   	
	value = jObj.get( KEY_PERMISSIONS );
	if( value != null &&  value instanceof String )
	{
		_policyKey = (String)value;
	}
   	
       value = jObj.get( KEY_PERMISSIONS );
       if (value != null  && value instanceof  JSONArray )
       {
       	JSONArray jArray = (JSONArray)value;
       	_permissions = new Permission[ jArray.size() ];

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


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