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


Java JSONObject.getJSONObject方法代码示例

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


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

示例1: WeatherItem

import org.json.JSONObject; //导入方法依赖的package包/类
public WeatherItem(JSONObject root) {

        try {

            timestmp = root.getLong("dt");

            JSONObject main = root.getJSONObject("main");
            temp = main.getDouble("temp");
            tempMin = main.getDouble("temp_min");
            tempMax = main.getDouble("temp_max");
            pressure = main.getDouble("pressure");
            humadity = main.getInt("humidity");

            JSONArray weather = root.getJSONArray("weather");
            JSONObject weatherObj = weather.getJSONObject(0);
            description = weatherObj.getString("description");
            iconUrl = weatherObj.getString("icon");
            id= weatherObj.getInt("id");
            mainDesc= weatherObj.getString("main");

            JSONObject wind = root.getJSONObject("wind");
            windSpeed = wind.getDouble("speed");
            windDeg = wind.getDouble("deg");

            isSuccess = true;
        } catch (JSONException e) {
            isSuccess = false;
            error = e + "";
        }

    }
 
开发者ID:shivam301296,项目名称:True-Weather,代码行数:32,代码来源:WeatherItem.java

示例2: fromJSON

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void fromJSON(JSONObject object, Database catalog_db) throws JSONException {
    JSONArray jsonArr = object.getJSONArray(Members.HISTOGRAM.name());
    this.histogram = new long[jsonArr.length()];
    this.clear();
    for (int i = 0; i < this.histogram.length; i++) {
        long delta = jsonArr.getLong(i);
        if (delta != NULL_COUNT) this.put(i, delta);
    } // FOR
    
    if (object.has(Members.DEBUG.name())) {
        if (this.debug_names == null) {
            this.debug_names = new TreeMap<Object, String>();
        } else {
            this.debug_names.clear();
        }
        JSONObject jsonObj = object.getJSONObject(Members.DEBUG.name());
        for (String key : CollectionUtil.iterable(jsonObj.keys())) {
            String label = jsonObj.getString(key);
            this.debug_names.put(Integer.valueOf(key), label);
        }
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:24,代码来源:FastIntHistogram.java

示例3: ImageLine

import org.json.JSONObject; //导入方法依赖的package包/类
ImageLine(JSONObject jsonLine) throws JSONException {
    mTextFields = new ArrayList<TextField>();

    JSONArray textValues = jsonLine.getJSONArray(ANSWERS_JSON_TEXT);
    for (int i = 0; i < textValues.length(); i++) {
        mTextFields.add(new TextField(textValues.getJSONObject(i)));
    }

    mAdditionalText = jsonLine.has(ANSWERS_JSON_ADDITIONAL_TEXT)
            ? new TextField(jsonLine.getJSONObject(ANSWERS_JSON_ADDITIONAL_TEXT))
            : null;

    mStatusText = jsonLine.has(ANSWERS_JSON_STATUS_TEXT)
            ? new TextField(jsonLine.getJSONObject(ANSWERS_JSON_STATUS_TEXT))
            : null;

    mImage = jsonLine.has(ANSWERS_JSON_IMAGE)
            ? jsonLine.getJSONObject(ANSWERS_JSON_IMAGE).getString(ANSWERS_JSON_IMAGE_DATA)
            : null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:SuggestionAnswer.java

示例4: createContainerPaymentMethod

import org.json.JSONObject; //导入方法依赖的package包/类
static PaymentMethod createContainerPaymentMethod(final JSONObject paymentMethodJSON, final String logoUrl)
        throws JSONException {
    final PaymentMethod paymentMethod = new PaymentMethod();

    final JSONObject group = paymentMethodJSON.getJSONObject("group");
    paymentMethod.type = group.getString("type");
    paymentMethod.name = group.getString("name");
    paymentMethod.logoUrl = logoUrl + group.getString("type") + ".png";
    paymentMethod.paymentMethodData = group.getString("paymentMethodData");

    final JSONArray inputDetails = paymentMethodJSON.optJSONArray("inputDetails");
    if (inputDetails != null) {
        paymentMethod.inputDetails = parseInputDetails(inputDetails);
    }

    return paymentMethod;
}
 
开发者ID:Adyen,项目名称:adyen-android,代码行数:18,代码来源:PaymentMethod.java

示例5: getCollationHit

import org.json.JSONObject; //导入方法依赖的package包/类
private long getCollationHit(JSONObject resultJson) throws JSONException
{
    JSONObject spellcheck = resultJson.getJSONObject("spellcheck");
    JSONArray suggestions = spellcheck.getJSONArray("suggestions");

    for (int key = 0, value = 1, length = suggestions.length(); value < length; key += 2, value += 2)
    {
        String jsonName = suggestions.getString(key);

        if ("collation".equals(jsonName))
        {
            JSONObject valueJsonObject = suggestions.getJSONObject(value);
            long collationHit = valueJsonObject.getLong("hits");
            return collationHit;
        }
    }

    return 0;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:SpellCheckDecisionManagerTest.java

示例6: DownloadArticle

import org.json.JSONObject; //导入方法依赖的package包/类
public Article DownloadArticle(String articleID) throws Exception {
    String articleResult = GetParam(downloadArticleURL + articleID, null);
    System.out.println(articleResult);
    JSONObject articleObject = new JSONObject(articleResult);
    JSONObject articleDetail = articleObject.getJSONObject("msg");
    Article article = new Article(articleDetail);
    System.out.println(article);
    return article;
}
 
开发者ID:zackszhu,项目名称:hack_sjtu_2017,代码行数:10,代码来源:HttpHandler.java

示例7: action

import org.json.JSONObject; //导入方法依赖的package包/类
public void action(final Event<JSONObject> event) throws EventException {
	final JSONObject data = event.getData();

	logger.debug("Processing an event[type={}, data={}] in listener[className={}]", event.getType(), data,
			RhythmArticleSender.class);
	try {
		final JSONObject originalArticle = data.getJSONObject(Article.ARTICLE);

		if (!originalArticle.getBoolean(Article.ARTICLE_IS_PUBLISHED)) {
			logger.debug("Ignores post article[title={}] to Rhythm",
					originalArticle.getString(Article.ARTICLE_TITLE));

			return;
		}

		final JSONObject preference = preferenceQueryService.getPreference();

		if (null == preference) {
			throw new EventException("Not found preference");
		}

		if (!StringUtils.isBlank(originalArticle.optString(Article.ARTICLE_VIEW_PWD))) {
			return;
		}

		if (Latkes.getServePath().contains("localhost")) {
			logger.info("Solo runs on local server, so should not send this article[id={}, title={}] to Rhythm",
					originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE));
			return;
		}

		final HTTPRequest httpRequest = new HTTPRequest();

		httpRequest.setURL(ADD_ARTICLE_URL);
		httpRequest.setRequestMethod(RequestMethod.POST);
		final JSONObject requestJSONObject = new JSONObject();
		final JSONObject article = new JSONObject();

		article.put(Keys.OBJECT_ID, originalArticle.getString(Keys.OBJECT_ID));
		article.put(Article.ARTICLE_TITLE, originalArticle.getString(Article.ARTICLE_TITLE));
		article.put(Article.ARTICLE_PERMALINK, originalArticle.getString(Article.ARTICLE_PERMALINK));
		article.put(Article.ARTICLE_TAGS_REF, originalArticle.getString(Article.ARTICLE_TAGS_REF));
		article.put(Article.ARTICLE_AUTHOR_EMAIL, originalArticle.getString(Article.ARTICLE_AUTHOR_EMAIL));
		article.put(Article.ARTICLE_CONTENT, originalArticle.getString(Article.ARTICLE_CONTENT));
		article.put(Article.ARTICLE_CREATE_DATE,
				((Date) originalArticle.get(Article.ARTICLE_CREATE_DATE)).getTime());
		article.put(Common.POST_TO_COMMUNITY, originalArticle.getBoolean(Common.POST_TO_COMMUNITY));

		// Removes this property avoid to persist
		originalArticle.remove(Common.POST_TO_COMMUNITY);

		requestJSONObject.put(Article.ARTICLE, article);
		requestJSONObject.put(Common.BLOG_VERSION, SoloConstant.VERSION);
		requestJSONObject.put(Common.BLOG, "B3log Solo");
		requestJSONObject.put(Option.ID_C_BLOG_TITLE, preference.getString(Option.ID_C_BLOG_TITLE));
		requestJSONObject.put("blogHost", Latkes.getServePath());
		requestJSONObject.put("userB3Key", preference.optString(Option.ID_C_KEY_OF_SOLO));
		requestJSONObject.put("clientAdminEmail", preference.optString(Option.ID_C_ADMIN_EMAIL));
		requestJSONObject.put("clientRuntimeEnv", Latkes.getRuntimeEnv().name());

		httpRequest.setPayload(requestJSONObject.toString().getBytes("UTF-8"));

		urlFetchService.fetchAsync(httpRequest);
	} catch (final Exception e) {
		logger.error("Sends an article to Rhythm error: {}", e.getMessage());
	}

	logger.debug("Sent an article to Rhythm");
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:70,代码来源:RhythmArticleSender.java

示例8: checkRuleComplete

import org.json.JSONObject; //导入方法依赖的package包/类
private void checkRuleComplete(JSONObject result) throws Exception
{
    assertNotNull("Response is null.", result);

    // if id present in response -> rule was created
    assertTrue(result.has("id"));

    assertEquals(result.getString("title"), "test_rule");
    assertEquals(result.getString("description"), "this is description for test_rule");

    JSONArray ruleType = result.getJSONArray("ruleType");

    assertEquals(1, ruleType.length());
    assertEquals("outbound", ruleType.getString(0));

    assertTrue(result.getBoolean("applyToChildren"));
    assertFalse(result.getBoolean("executeAsynchronously"));
    assertFalse(result.getBoolean("disabled"));
    assertTrue(result.has("owningNode"));
    JSONObject owningNode = result.getJSONObject("owningNode");
    assertTrue(owningNode.has("nodeRef"));
    assertTrue(owningNode.has("name"));
    assertTrue(result.has("url"));

    JSONObject jsonAction = result.getJSONObject("action");

    assertTrue(jsonAction.has("id"));

    assertEquals(jsonAction.getString("actionDefinitionName"), "composite-action");
    assertEquals(jsonAction.getString("description"), "this is description for composite-action");
    assertEquals(jsonAction.getString("title"), "test_title");

    assertTrue(jsonAction.getBoolean("executeAsync"));

    assertTrue(jsonAction.has("actions"));
    assertTrue(jsonAction.has("conditions"));
    assertTrue(jsonAction.has("compensatingAction"));
    assertTrue(jsonAction.has("url"));
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:40,代码来源:RuleServiceTest.java

示例9: parseJSON

import org.json.JSONObject; //导入方法依赖的package包/类
private void parseJSON(String data) throws JSONException {
    if (data == null)
        return;

    Route route = null;
    List<Route> routes = new ArrayList<>();
    JSONObject jsonData = new JSONObject(data);
    JSONArray jsonRoutes = jsonData.getJSONArray("routes");
    for (int i = 0; i < jsonRoutes.length(); i++) {
        JSONObject jsonRoute = jsonRoutes.getJSONObject(i);
        route = new Route();

        JSONObject overview_polylineJson = jsonRoute.getJSONObject("overview_polyline");
        JSONArray jsonLegs = jsonRoute.getJSONArray("legs");
        JSONObject jsonLeg = jsonLegs.getJSONObject(0);
        JSONObject jsonDistance = jsonLeg.getJSONObject("distance");
        JSONObject jsonDuration = jsonLeg.getJSONObject("duration");
        JSONObject jsonEndLocation = jsonLeg.getJSONObject("end_location");
        JSONObject jsonStartLocation = jsonLeg.getJSONObject("start_location");

        route.setDistance(new Distance(jsonDistance.getString("text"), jsonDistance.getInt("value")));
        route.setDuration(new Duration(jsonDuration.getString("text"), jsonDuration.getInt("value")));
        route.setEndAddress(jsonLeg.getString("end_address"));
        route.setStartAddress(jsonLeg.getString("start_address"));
        route.setStartLocation(new LatLng(jsonStartLocation.getDouble("lat"), jsonStartLocation.getDouble("lng")));
        route.setEndLocation(new LatLng(jsonEndLocation.getDouble("lat"), jsonEndLocation.getDouble("lng")));
        route.setPoints(decodePolyLine(overview_polylineJson.getString("points")));

        routes.add(route);
    }

    listener.onDirectionFinderSuccess(routes, route);
}
 
开发者ID:Balthair94,项目名称:AppGoogleMaps,代码行数:34,代码来源:DownloadRawData.java

示例10: RemoteNodeData

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * the constructor.
 *
 * @param config
 *            the configuration to use.
 */
public RemoteNodeData(final JSONObject config) {
	final JSONObject timersJson = config.getJSONObject(ConfigurationUtil.TIMERS);
	timersMap = TimerUtil.getTimerMap(timersJson);
	sleepIntervalMs = JsonUtil.getTime(config, ConfigurationUtil.SLEEP_INTERVAL);
	recycleIntervalMs = JsonUtil.getTime(config, ConfigurationUtil.RECYCLE_INTERVAL);
}
 
开发者ID:coranos,项目名称:neo-java,代码行数:13,代码来源:RemoteNodeData.java

示例11: doInBackground

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(Context... params) {

    HttpResponse response;
    try {
        LocationManager lm = (LocationManager) params[0].getSystemService(Context.LOCATION_SERVICE);
        Criteria crit = new Criteria();
        crit.setAccuracy(Criteria.ACCURACY_FINE);
        String provider = lm.getBestProvider(crit, true);

        Location loc = lm.getLastKnownLocation(provider);

        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet();

        request.setURI(new URI(Utils.WEATHER_URL + "lat=" +
                loc.getLatitude() +
                "&lon=" +
                +loc.getLongitude()
                + "&units=metric"));

        response = client.execute(request);
        String result = EntityUtils.toString(response.getEntity());
        JSONObject jsonResponse = new JSONObject(result);
        JSONObject jsonWeather = jsonResponse.getJSONObject("main");
        return jsonWeather.getInt("temp");

    } catch (Exception e) {
        error = e;
    }
    return 0;
}
 
开发者ID:feup-infolab,项目名称:labtablet,代码行数:33,代码来源:AsyncWeatherFetcher.java

示例12: process

import org.json.JSONObject; //导入方法依赖的package包/类
@Override
public void process(JSONObject content, JSONObject rawRequest, Server server) {
    JSONObject user = content.getJSONObject("user");
    GroupUser gUser = server.getGroupUserById(user.getString("id"));
    server.getConnectedClients().remove(gUser);
    api.getEventManager().executeEvent(new UserBannedEvent(server, gUser));
}
 
开发者ID:discord-java,项目名称:discord.jar,代码行数:8,代码来源:BanPoll.java

示例13: a

import org.json.JSONObject; //导入方法依赖的package包/类
private void a(String str) {
    String str2;
    try {
        JSONObject jSONObject = new JSONObject(str);
        String string = jSONObject.getString("clientId");
        try {
            if (!TextUtils.isEmpty(string)) {
                JSONObject jSONObject2 = jSONObject.getJSONObject("param");
                if (jSONObject2 instanceof JSONObject) {
                    jSONObject2 = jSONObject2;
                } else {
                    jSONObject2 = null;
                }
                String string2 = jSONObject.getString(a.g);
                String string3 = jSONObject.getString(a.d);
                a aVar = new a("call");
                aVar.j = string3;
                aVar.k = string2;
                aVar.m = jSONObject2;
                aVar.i = string;
                a(aVar);
            }
        } catch (Exception e) {
            str2 = string;
            if (!TextUtils.isEmpty(str2)) {
                try {
                    a(str2, a.RUNTIME_ERROR);
                } catch (JSONException e2) {
                }
            }
        }
    } catch (Exception e3) {
        str2 = null;
        if (!TextUtils.isEmpty(str2)) {
            a(str2, a.RUNTIME_ERROR);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:39,代码来源:d.java

示例14: getGeocodeResults

import org.json.JSONObject; //导入方法依赖的package包/类
private GeocodingResult[] getGeocodeResults(String respContent, SearchBoundary boundary)
{
	JSONObject features = new JSONObject(respContent);
	JSONArray arr = (JSONArray)features.get("features");

	GeocodingResult[] results = new GeocodingResult[arr.length()];
	
	for (int j = 0; j < arr.length(); j++) {
		JSONObject feature = arr.getJSONObject(j);
		JSONObject geomObj = feature.getJSONObject("geometry");
		JSONArray coordsObj = geomObj.getJSONArray("coordinates");
		
		double lon = Double.parseDouble(coordsObj.get(0).toString());
		double lat = Double.parseDouble(coordsObj.get(1).toString());
		
		if (boundary != null && !boundary.contains(lon, lat))
			continue;		

		JSONObject props = feature.getJSONObject("properties");

		String country = props.optString("country");
		String state = props.optString("state");
		String postal_code = props.optString("postcode");
		String locality = props.optString("city");
		String street = props.optString("street");
		String house_number = props.optString("housenumber");
		String name = props.optString("name");
		String house = name;
		String osm_value = props.optString("osm_value");
		if (!Helper.isEmpty(osm_value))
		{
			String osm_key = props.optString("osm_key");
			if (osm_value.equals("district"))
			{
				//state_district = osm_key;
			}
			else if (osm_value.equals("state") && osm_key.equals("place"))
				state = name;
		}

		if (state != null || locality != null || street != null) {
			GeocodingResult gr = new GeocodingResult();
			gr.locality = locality;
			gr.country = country;
			gr.region = state;
			//gr.stateDistrict = state_district;
			gr.postalCode = postal_code;
			gr.street = street;
			gr.name = house;
			gr.houseNumber = house_number;
			gr.longitude = lon;
			gr.latitude = lat;
			
			results[j] = gr;
		}
	}
	
	Arrays.sort(results, new GeocodingResultComparator());
	
	return results;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:62,代码来源:PhotonGeocoder.java

示例15: Annotation

import org.json.JSONObject; //导入方法依赖的package包/类
public Annotation(JSONObject obj) throws JSONException {
    timestamp = obj.getLong("1");
    JSONObject info = obj.getJSONObject("2");
    desc = info.getString("3");
    type = Type.parse(info.getInt("4"));
}
 
开发者ID:devgianlu,项目名称:PlayConsoleAndroidAPI,代码行数:7,代码来源:Annotation.java


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