如何从 JSON 回复中提取有意义的信息? [复制]

2024-01-10

回复 印度孟买

{   "response": {       "version": "0.1"        
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html"        
"features": {       "geolookup": 1      
        "conditions": 1     
        "forecast": 1       }   }       
    "location": {       "type":"INTLCITY"
        "country":"IN"
        "country_iso3166":"IN"
        "country_name":"India"
        "state":""
        "city":"Mumbai"
        "tz_short":"IST"
        "tz_long":"Asia/Kolkata"
        "lat":"19.12000084"
        "lon":"72.84999847"
        "zip":"00000"
        "magic":"1"
        "wmo":"43003"
        "l":"/q/zmw:00000.1.43003"
        "requesturl":"global/stations/43003.html"
        "wuiurl":"http://www.wunderground.com/global/stations/43003.html"
        "nearby_weather_stations": {        "airport": {        "station": [        { "city":"Mumbai / Santacruz"
 "state":""
 "country":"India"
 "icao":"VABB"
 "lat":"19.11666679"
 "lon":"72.84999847" }
        { "city":"Mumbai"
 "state":""
 "country":"IN"
 "icao":"VABB"
 "lat":"19.12000084"
 "lon":"72.84999847" }      ]       }       
        "pws": {        "station": [        ]       }       }   }       
    "current_observation": {        "image": {      "url":"http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png"
        "title":"Weather Underground"
        "link":"http://www.wunderground.com"        }
        "display_location": {       "full":"Mumbai
 India"
        "city":"Mumbai"
        "state":""
        "state_name":"India"
        "country":"IN"
        "country_iso3166":"IN"
        "zip":"00000"
        "latitude":"19.12000084"
        "longitude":"72.84999847"
        "elevation":"14.00000000"       }
        "observation_location": {       "full":"Mumbai
 "
        "city":"Mumbai"
        "state":""
        "country":"IN"
        "country_iso3166":"IN"
        "latitude":"19.12000084"
        "longitude":"72.84999847"
        "elevation":"46 ft"     }
        "estimated": {      }
        "station_id":"VABB"
        "observation_time":"Last Updated on February 16
 5:10 PM IST"
        "observation_time_rfc822":"Sat
 16 Feb 2013 17:10:00 +0530"
        "observation_epoch":"1361014800"
        "local_time_rfc822":"Sat
 16 Feb 2013 17:25:20 +0530"
        "local_epoch":"1361015720"
        "local_tz_short":"IST"
        "local_tz_long":"Asia/Kolkata"
        "local_tz_offset":"+0530"
        "weather":"Clear"
        "temperature_string":"77 F (25 C)"
        "temp_f":77
        "temp_c":25
        "relative_humidity":"54%"
        "wind_string":"From the WNW at 8 MPH"
        "wind_dir":"WNW"
        "wind_degrees":290
        "wind_mph":8
        "wind_gust_mph":0
        "wind_kph":13
        "wind_gust_kph":0
        "pressure_mb":"1008"
        "pressure_in":"29.77"
        "pressure_trend":"0"
        "dewpoint_string":"59 F (15 C)"
        "dewpoint_f":59
        "dewpoint_c":15
        "heat_index_string":"NA"
        "heat_index_f":"NA"
        "heat_index_c":"NA"
        "windchill_string":"NA"
        "windchill_f":"NA"
        "windchill_c":"NA"
        "feelslike_string":"77 F (25 C)"
        "feelslike_f":"77"
        "feelslike_c":"25"
        "visibility_mi":"3.7"
        "visibility_km":"6.0"
        "solarradiation":""
        "UV":"-1"
        "precip_1hr_string":"-9999.00 in (-9999.00 mm)"
        "precip_1hr_in":"-9999.00"
        "precip_1hr_metric":"-9999.00"
        "precip_today_string":"0.00 in (0.0 mm)"
        "precip_today_in":"0.00"
        "precip_today_metric":"0.0"
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "forecast_url":"http://www.wunderground.com/global/stations/43003.html"
        "history_url":"http://www.wunderground.com/history/airport/VABB/2013/2/16/DailyHistory.html"
        "ob_url":"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=19.12000084
72.84999847"    }       
    "forecast":{        "txt_forecast": {       "date":"5:30 AM IST"
        "forecastday": [        {       "period":0
        "icon":"chancerain"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif"
        "title":"Saturday"
        "fcttext":"Partly cloudy with a chance of rain in the morning
 then clear. High of 81F. Winds from the WNW at 10 to 15 mph. Chance of rain 30%."
        "fcttext_metric":"Partly cloudy with a chance of rain in the morning
 then clear. High of 27C. Breezy. Winds from the WNW at 15 to 25 km/h. Chance of rain 30%."
        "pop":"30"      }       
        {       "period":1
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "title":"Saturday Night"
        "fcttext":"Clear. Low of 68F. Winds less than 5 mph."
        "fcttext_metric":"Clear. Low of 20C. Winds less than 5 km/h."
        "pop":"0"       }       
        {       "period":2
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "title":"Sunday"
        "fcttext":"Clear. High of 82F. Winds from the NE at 5 to 15 mph shifting to the WNW in the afternoon."
        "fcttext_metric":"Clear. High of 28C. Winds from the NE at 5 to 20 km/h shifting to the WNW in the afternoon."
        "pop":"0"       }       
        {       "period":3
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "title":"Sunday Night"
        "fcttext":"Clear. Low of 66F. Winds from the NNE at 5 to 10 mph."
        "fcttext_metric":"Clear. Low of 19C. Winds from the NNE at 10 to 15 km/h."
        "pop":"0"       }       
        {       "period":4
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "title":"Monday"
        "fcttext":"Clear. High of 88F. Winds from the NNE at 5 to 15 mph shifting to the NW in the afternoon."
        "fcttext_metric":"Clear. High of 31C. Breezy. Winds from the NNE at 10 to 20 km/h shifting to the NW in the afternoon."
        "pop":"0"       }       
        {       "period":5
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "title":"Monday Night"
        "fcttext":"Clear. Low of 63F. Winds from the NNE at 5 to 10 mph."
        "fcttext_metric":"Clear. Low of 17C. Winds from the NNE at 5 to 15 km/h."
        "pop":"0"       }       
        {       "period":6
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "title":"Tuesday"
        "fcttext":"Clear. High of 90F. Winds from the North at 5 to 10 mph shifting to the WNW in the afternoon."
        "fcttext_metric":"Clear. High of 32C. Winds from the North at 5 to 20 km/h shifting to the WNW in the afternoon."
        "pop":"0"       }       
        {       "period":7
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "title":"Tuesday Night"
        "fcttext":"Clear. Low of 72F. Winds from the North at 5 to 10 mph."
        "fcttext_metric":"Clear. Low of 22C. Winds from the North at 5 to 15 km/h."
        "pop":"0"       }       ]       }
        "simpleforecast": {     "forecastday": [        {"date":{   "epoch":"1361037600"
    "pretty":"11:30 PM IST on February 16
 2013"
    "day":16
    "month":2
    "year":2013
    "yday":46
    "hour":23
    "min":"30"
    "sec":0
    "isdst":"0"
    "monthname":"February"
    "weekday_short":"Sat"
    "weekday":"Saturday"
    "ampm":"PM"
    "tz_short":"IST"
    "tz_long":"Asia/Kolkata"}
        "period":1
        "high": {       "fahrenheit":"81"
        "celsius":"27"      }
        "low": {        "fahrenheit":"68"
        "celsius":"20"      }
        "conditions":"Chance of Rain"
        "icon":"chancerain"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif"
        "skyicon":"mostlysunny"
        "pop":30
        "qpf_allday": {     "in": 0.01
        "mm": 0.3       }
        "qpf_day": {        "in": 0.00
        "mm": 0.0       }
        "qpf_night": {      "in": 0.00
        "mm": 0.0       }
        "snow_allday": {        "in": 0
        "cm": 0     }
        "snow_day": {       "in": 0
        "cm": 0     }
        "snow_night": {     "in": 0
        "cm": 0     }
        "maxwind": {        "mph": 14
        "kph": 22
        "dir": "WNW"
        "degrees": 294      }
        "avewind": {        "mph": 12
        "kph": 19
        "dir": "WNW"
        "degrees": 295      }
        "avehumidity": 53
        "maxhumidity": 72
        "minhumidity": 49       }       
        {"date":{   "epoch":"1361124000"
    "pretty":"11:30 PM IST on February 17
 2013"
    "day":17
    "month":2
    "year":2013
    "yday":47
    "hour":23
    "min":"30"
    "sec":0
    "isdst":"0"
    "monthname":"February"
    "weekday_short":"Sun"
    "weekday":"Sunday"
    "ampm":"PM"
    "tz_short":"IST"
    "tz_long":"Asia/Kolkata"}
        "period":2
        "high": {       "fahrenheit":"82"
        "celsius":"28"      }
        "low": {        "fahrenheit":"66"
        "celsius":"19"      }
        "conditions":"Clear"
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "skyicon":"sunny"
        "pop":0
        "qpf_allday": {     "in": 0.00
        "mm": 0.0       }
        "qpf_day": {        "in": 0.00
        "mm": 0.0       }
        "qpf_night": {      "in": 0.00
        "mm": 0.0       }
        "snow_allday": {        "in": 0
        "cm": 0     }
        "snow_day": {       "in": 0
        "cm": 0     }
        "snow_night": {     "in": 0
        "cm": 0     }
        "maxwind": {        "mph": 11
        "kph": 18
        "dir": "NW"
        "degrees": 306      }
        "avewind": {        "mph": 8
        "kph": 13
        "dir": "WSW"
        "degrees": 238      }
        "avehumidity": 55
        "maxhumidity": 64
        "minhumidity": 39       }       
        {"date":{   "epoch":"1361210400"
    "pretty":"11:30 PM IST on February 18
 2013"
    "day":18
    "month":2
    "year":2013
    "yday":48
    "hour":23
    "min":"30"
    "sec":0
    "isdst":"0"
    "monthname":"February"
    "weekday_short":"Mon"
    "weekday":"Monday"
    "ampm":"PM"
    "tz_short":"IST"
    "tz_long":"Asia/Kolkata"}
        "period":3
        "high": {       "fahrenheit":"88"
        "celsius":"31"      }
        "low": {        "fahrenheit":"63"
        "celsius":"17"      }
        "conditions":"Clear"
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "skyicon":"sunny"
        "pop":0
        "qpf_allday": {     "in": 0.00
        "mm": 0.0       }
        "qpf_day": {        "in": 0.00
        "mm": 0.0       }
        "qpf_night": {      "in": 0.00
        "mm": 0.0       }
        "snow_allday": {        "in": 0
        "cm": 0     }
        "snow_day": {       "in": 0
        "cm": 0     }
        "snow_night": {     "in": 0
        "cm": 0     }
        "maxwind": {        "mph": 12
        "kph": 19
        "dir": "NW"
        "degrees": 310      }
        "avewind": {        "mph": 9
        "kph": 14
        "dir": "SW"
        "degrees": 235      }
        "avehumidity": 44
        "maxhumidity": 62
        "minhumidity": 30       }       
        {"date":{   "epoch":"1361296800"
    "pretty":"11:30 PM IST on February 19
 2013"
    "day":19
    "month":2
    "year":2013
    "yday":49
    "hour":23
    "min":"30"
    "sec":0
    "isdst":"0"
    "monthname":"February"
    "weekday_short":"Tue"
    "weekday":"Tuesday"
    "ampm":"PM"
    "tz_short":"IST"
    "tz_long":"Asia/Kolkata"}
        "period":4
        "high": {       "fahrenheit":"90"
        "celsius":"32"      }
        "low": {        "fahrenheit":"72"
        "celsius":"22"      }
        "conditions":"Clear"
        "icon":"clear"
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif"
        "skyicon":"sunny"
        "pop":0
        "qpf_allday": {     "in": 0.00
        "mm": 0.0       }
        "qpf_day": {        "in": 0.00
        "mm": 0.0       }
        "qpf_night": {      "in": 0.00
        "mm": 0.0       }
        "snow_allday": {        "in": 0
        "cm": 0     }
        "snow_day": {       "in": 0
        "cm": 0     }
        "snow_night": {     "in": 0
        "cm": 0     }
        "maxwind": {        "mph": 10
        "kph": 16
        "dir": "WNW"
        "degrees": 302      }
        "avewind": {        "mph": 8
        "kph": 13
        "dir": "West"
        "degrees": 272      }
        "avehumidity": 46
        "maxhumidity": 51
        "minhumidity": 30       }       ]       }   }}
---------------------------
        mph: 8,  

回复 澳大利亚 悉尼

{   "response": {       "version": "0.1"        
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html"        
"features": {       "geolookup": 1      
        "conditions": 1     
        "forecast": 1       }   }       
    "location": {       "type":"INTLCITY"
        "country":"AU"
        "country_iso3166":"AU"
        "country_name":"Australia"
        "state":"NW"
        "city":"Sydney"
        "tz_short":"EST"
        "tz_long":"Australia/Sydney"
        "lat":"-33.95000076"
        "lon":"151.17999268"
        "zip":"00000"
        "magic":"1"
        "wmo":"94767"
        "l":"/q/zmw:00000.1.94767"
        "requesturl":"global/stations/94767.html"
        "wuiurl":"http://www.wunderground.com/global/stations/94767.html"
        "nearby_weather_stations": {        "airport": {        "station": [        { "city":"Sydney Airport"
 "state":""
 "country":"Australia"
 "icao":"YSSY"
 "lat":"-33.95000076"
 "lon":"151.18333435" }
        { "city":"Sydney"
 "state":""
 "country":"AU"
 "icao":"YSSY"
 "lat":"-33.95000076"
 "lon":"151.17999268" }
        { "city":"Richmond (NSW)"
 "state":""
 "country":"AU"
 "icao":"YSRI"
 "lat":"-33.59999847"
 "lon":"150.77999878" }     ]       }       
        "pws": {        "station": [        {       "neighborhood":"Matraville"
        "city":"Sydney"
        "state":"NSW"
        "country":"AUSTRALIA"
        "id":"INSWMATR2"
        "lat":-33.957550
        "lon":151.230850
        "distance_km":4
        "distance_mi":2     }
        {       "neighborhood":"Bardwell Park"
        "city":"Sydney"
        "state":"New South Wales"
        "country":"AUSTRALIA"
        "id":"INEWSOUT37"
        "lat":-33.938381
        "lon":151.124359
        "distance_km":5
        "distance_mi":3     }
        {       "neighborhood":"APRSWXNET Sydney AU"
        "city":"Little Bay"
        "state":"NW"
        "country":"AU"
        "id":"MD5399"
        "lat":-33.958500
        "lon":151.240677
        "distance_km":5
        "distance_mi":3     }
        {       "neighborhood":""
        "city":"Pyrmont"
        "state":"NEW SOUTH WALES"
        "country":"AUSTRALIA"
        "id":"INEWSOUT155"
        "lat":-33.871807
        "lon":151.194977
        "distance_km":8
        "distance_mi":5     }
        {       "neighborhood":"Woolloomooloo"
        "city":"Woolloomooloo"
        "state":"NSW"
        "country":"AUSTRALIA"
        "id":"INSWWOOL3"
        "lat":-33.874527
        "lon":151.220734
        "distance_km":9
        "distance_mi":5     }
        {       "neighborhood":"Old\u0027s Park"
        "city":"Penshurst"
        "state":"NSW"
        "country":"AUSTRALIA"
        "id":"INSWPENS2"
        "lat":-33.958290
        "lon":-208.924866
        "distance_km":9
        "distance_mi":5     }
        {       "neighborhood":"Searl Road"
        "city":"Cronulla"
        "state":"NSW"
        "country":"AUSTRALIA"
        "id":"INSWCRON2"
        "lat":-34.052074
        "lon":151.148605
        "distance_km":11
        "distance_mi":7     }
        {       "neighborhood":"Cronulla - Cecil Apartments"
        "city":"Cronulla - Sydney"
        "state":"NSW"
        "country":"AUSTRALIA"
        "id":"INSWSYDN19"
        "lat":-34.054329
        "lon":151.153656
        "distance_km":11
        "distance_mi":7     }
        {       "neighborhood":"The Shire - Caringbah South"
        "city":"Sydney"
        "state":"New South Wales"
        "country":"Australia"
        "id":"INSWCARI2"
        "lat":-34.048203
        "lon":151.120697
        "distance_km":12
        "distance_mi":7     }
        {       "neighborhood":"Kareela"
        "city":"Kareela"
        "state":"NSW"
        "country":"AUSTRALIA"
        "id":"INSWKIRR2"
        "lat":-34.020538
        "lon":151.075287
        "distance_km":12
        "distance_mi":7     }
        {       "neighborhood":"Caringbah South"
        "city":"Caringbah South"
        "state":"NSW"
        "country":"AUSTRALIA"
        "id":"INSWCARI3"
        "lat":-34.054550
        "lon":151.115799
        "distance_km":13
        "distance_mi":7     }
        {       "neighborhood":"Sutherland Shire"
        "city":"Caringbah South"
        "state":"NEW SOUTH WALES"
        "country":"Australia"
        "id":"INEWSOUT125"
        "lat":-34.059315
        "lon":151.117416
        "distance_km":13
        "distance_mi":8     }
        {       "neighborhood":"Lower North Shore"
        "city":"Linley Point (Lane Cove)"
        "state":"NEW SOUTH WALES"
        "country":"AUSTRALIA"
        "id":"INEWSOUT83"
        "lat":-33.826977
        "lon":151.151077
        "distance_km":13
        "distance_mi":8     }
        {       "neighborhood":"Gymea Bay South of Sydney near Royal National Park"
        "city":"Sydney"
        "state":"NSW"
        "country":"Australia"
        "id":"ISYDNEY2"
        "lat":-34.047691
        "lon":151.079971
        "distance_km":14
        "distance_mi":8     }
        {       "neighborhood":"Willoughby"  
[some more text here]
    ---------------------------
            mph: 7,  

问题

这是来自的回复Weather Underground对于两个不同的城市。对于孟买,它仅提供有关一个城市的数据,但对于悉尼,它提供有关悉尼周边许多地点的数据。

我希望能够从中提取信息JSON以一致的方式答复。到目前为止,我使用String一些不太可靠的提取方法。
我该如何去做呢?

Code

package test;

import java.net.*;
import java.io.*;

import org.apache.commons.lang3.text.WordUtils;

import com.google.gson.*;
import com.google.gson.stream.JsonReader;


public class TestGson {

    URL callToApi;
//------------------------------------------------------------------------------
    public static void main(String[] args) {
        new TestGson();
    }
//------------------------------------------------------------------------------
    public TestGson(){
        try{
            sendCallToApi();
            readJson();
        }catch(IOException e){
            e.printStackTrace();
        }
    }
//------------------------------------------------------------------------------
    public void sendCallToApi(){
        try{
            callToApi = new URL("http://api.wunderground.com/api" +
                    "/[API KEY HERE]" +
                    "/geolookup/conditions/forecast/q/" +
                    "Australia/" +
                    "Sydney.json");
        }catch(MalformedURLException e){
            e.printStackTrace();
        }
    }
//------------------------------------------------------------------------------
    public void readJson() throws IOException{
        Gson g = new Gson();
        String wdf = null;
        InputStreamReader in = new InputStreamReader(callToApi.openStream());
        BufferedReader reader = new BufferedReader(in);
        String message = "hello";
        StringBuffer buf = new StringBuffer();

        while(true){
            message = reader.readLine();

            if(message == null){
                break;
            }else{
                if(message.contains("mph")){
                    wdf = message;
                }
                buf.append(message);
            }
        }
        message = buf.toString();
        System.out.println(message.replaceAll(",","\n"));
        System.out.println("---------------------------");
        wdf = wdf.replace("\"", "");
        System.out.println(wdf);
    }
//------------------------------------------------------------------------------
}

JSON 是一个序列化对象——这意味着它非常适合反序列化。这允许您将 JSON 转换为可以随意查询的 java 对象。
首先,您需要一个合适的 java bean - JSON 的结构很简单,因此应该不难。
然后您可以使用诸如Jackson http://wiki.fasterxml.com/JacksonHome读取您的数据并将其放入 bean 中。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何从 JSON 回复中提取有意义的信息? [复制] 的相关文章

  • 在画布上绘图

    我正在编写一个 Android 应用程序 它可以在视图的 onDraw 事件上直接绘制到画布上 我正在绘制一些涉及单独绘制每个像素的东西 为此我使用类似的东西 for int x 0 x lt xMax x for int y 0 y lt
  • 在 java 类和 android 活动之间传输时音频不清晰

    我有一个android活动 它连接到一个java类并以套接字的形式向它发送数据包 该类接收声音数据包并将它们扔到 PC 扬声器 该代码运行良好 但在 PC 扬声器中播放声音时会出现持续的抖动 中断 安卓活动 public class Sen
  • 使用 Android 发送 HTTP Post 请求

    我一直在尝试从 SO 和其他网站上的大量示例中学习 但我无法弄清楚为什么我编写的示例不起作用 我正在构建一个小型概念验证应用程序 它可以识别语音并将其 文本 作为 POST 请求发送到 node js 服务器 我已确认语音识别有效 并且服务
  • 多个 Maven 配置文件激活多个 Spring 配置文件

    我想在 Maven 中构建一个环境 在其中我想根据哪些 Maven 配置文件处于活动状态来累积激活多个 spring 配置文件 目前我的 pom xml 的相关部分如下所示
  • jQuery AJAX 请求在 IE8 中失败,并显示消息“错误:调用 open 方法之前无法调用此方法。”

    我正在使用 jQuery 1 4 2 并尝试执行一个简单的 AJAX 请求 目标 URL 返回一个 JSON 字符串 我使用 jslint 对其进行了验证 该请求在 Firefox 和 Chrome 中有效 但不想在 IE8 中工作 我无法
  • 如何为俚语和表情符号构建正则表达式 (regex)

    我需要构建一个正则表达式来匹配俚语 即 lol lmao imo 等 和表情符号 即 P 等 我按照以下示例进行操作http www coderanch com t 497238 java java Regular Expression D
  • 如何格式化 Json 输出

    请帮助我如何获取 JSON 输出 如下所示 costMethod Average fundingDate 2008 10 02 fundingAmount 2510959 95 代替 type sma costMethod Average
  • 使用Caliper时如何指定命令行?

    我发现 Google 的微型基准测试项目 Caliper 非常有趣 但文档仍然 除了一些示例 完全不存在 我有两种不同的情况 需要影响 JVM Caliper 启动的命令行 我需要设置一些固定 最好在几个固定值之间交替 D 参数 我需要指定
  • Java Integer CompareTo() - 为什么使用比较与减法?

    我发现java lang Integer实施compareTo方法如下 public int compareTo Integer anotherInteger int thisVal this value int anotherVal an
  • 如何在控制器、服务和存储库模式中使用 DTO

    我正在遵循控制器 服务和存储库模式 我只是想知道 DTO 在哪里出现 控制器应该只接收 DTO 吗 我的理解是您不希望外界了解底层域模型 从领域模型到 DTO 的转换应该发生在控制器层还是服务层 在今天使用 Spring MVC 和交互式
  • AWS 无法从 START_OBJECT 中反序列化 java.lang.String 实例

    我创建了一个 Lambda 函数 我想在 API 网关的帮助下通过 URL 访问它 我已经把一切都设置好了 我还创建了一个application jsonAPI Gateway 中的正文映射模板如下所示 input input params
  • 在 Mac 上正确运行基于 SWT 的跨平台 jar

    我一直致力于一个基于 SWT 的项目 该项目旨在部署为 Java Web Start 从而可以在多个平台上使用 到目前为止 我已经成功解决了由于 SWT 依赖的系统特定库而出现的导出问题 请参阅相关thread https stackove
  • Eclipse Java 远程调试器通过 VPN 速度极慢

    我有时被迫离开办公室工作 这意味着我需要通过 VPN 进入我的实验室 我注意到在这种情况下使用 Eclipse 进行远程调试速度非常慢 速度慢到调试器需要 5 7 分钟才能连接到远程 jvm 连接后 每次单步执行断点 行可能需要 20 30
  • 如何在 Python 中追加到 JSON 文件?

    我有一个 JSON 文件 其中包含 67790 1 kwh 319 4 现在我创建一个字典a dict我需要将其附加到 JSON 文件中 我尝试了这段代码 with open DATA FILENAME a as f json obj js
  • 玩!框架:运行“h2-browser”可以运行,但网页不可用

    当我运行命令时activator h2 browser它会使用以下 url 打开浏览器 192 168 1 17 8082 但我得到 使用 Chrome 此网页无法使用 奇怪的是它以前确实有效 从那时起我唯一改变的是JAVA OPTS以启用
  • simpleframework,将空元素反序列化为空字符串而不是 null

    我使用简单框架 http simple sourceforge net http simple sourceforge net 在一个项目中满足我的序列化 反序列化需求 但在处理空 空字符串值时它不能按预期工作 好吧 至少不是我所期望的 如
  • 捕获的图像分辨率太大

    我在做什么 我允许用户捕获图像 将其存储到 SD 卡中并上传到服务器 但捕获图像的分辨率为宽度 4608 像素和高度 2592 像素 现在我想要什么 如何在不影响质量的情况下获得小分辨率图像 例如我可以获取或设置捕获的图像分辨率为原始图像分
  • 有没有办法为Java的字符集名称添加别名

    我收到一个异常 埋藏在第 3 方库中 消息如下 java io UnsupportedEncodingException BIG 5 我认为发生这种情况是因为 Java 没有定义这个名称java nio charset Charset Ch
  • 如何修复 JNLP 应用程序中的“缺少代码库、权限和应用程序名称清单属性”?

    随着最近的 Java 更新 许多人都遇到了缺少 Java Web Start 应用程序的问题Codebase Permissions and Application name体现属性 尽管有资源可以帮助您完成此任务 但我找不到任何资源综合的
  • 将 List 转换为 JSON

    Hi guys 有人可以帮助我 如何将我的 HQL 查询结果转换为带有对象列表的 JSON 并通过休息服务获取它 这是我的服务方法 它返回查询结果列表 Override public List

随机推荐

  • Python 静态方法并不总是可调用的

    在解析属性时使用 dict https docs python org 3 library stdtypes html object dict my staticmethod https docs python org 3 library
  • 使用 rsync(或 svn、git、cvs)进行部署并忽略部署期间不一致的状态?

    我们目前正在讨论通过 rsync 部署网站 但是 在 rsync 过程中 应用程序处于不一致的状态 因为某些文件可能已经同步 而其他文件仍保留旧版本 对吗 人们如何处理这个问题 我猜想通过 svn git cvs 部署时也存在同样的问题 我
  • MongoDB 中的查询

    我正在尝试使用rmongodb从 MongoDB 数据库获取信息以便在 R 中进一步处理 但是 我在真正开始时遇到了一些困难 这个有效 cursor lt mongo find mongo people query list last na
  • iOS 上的 Xamarin Forms 如何设置页面的屏幕方向?

    所以标题说明了一切 我现在对 iOS 很关心 我试图起诉我的基本页面 LandscapeContentPage 的自定义渲染器 这希望强制它呈现为横向 我没有成功 我尝试使用我发现的一个 hack 在 ViewDidAppear 中你提供了
  • 回形针 - 每个样式的默认样式?可能的

    我正在使用回形针 并且有多种样式 styles gt large gt 300x300 gt medium gt 150x150 gt small gt 50x50 gt thumb gt 30x30 gt 问题是default stype
  • Linux下自动调整进程优先级

    我正在尝试编写一个程序 根据配置文件 基本上是路径 优先级对 自动设置进程优先级 我认为最好的解决方案是用一个内核模块来替换 execve 系统调用 太糟糕了 系统调用表在内核版本 gt 2 6 0 中没有导出 因此如果没有系统调用表 就不
  • Crashlytics 记录错误

    我正在使用 iOS 版 Crashlytics 记录错误 NSDictionary detail message errorWithURL response jsonString Crashlytics sharedInstance rec
  • 如何通过代理/防火墙添加网络引用?

    我目前在工作中处于防火墙后面 我正在测试已部署到 我的网站的某些内容 并且工作代理似乎在某种程度上阻止了它 基本上我收到的消息是 由于对象的当前状态 操作无效 我已将其归结为我的代理干扰 但我看不到任何高级设置或任何可以设置为通过我的代理访
  • Python:解析 JSON 时出现 Keyerror

    我刚刚编写了一个程序来解析 api 中的一些数据 API 以 JSON 格式返回数据 当我尝试解析它时 它给了我一个关键错误 Traceback most recent call last File test py line 20 in
  • 避免 Python 中不必要的切片复制

    对于这样的情况 是否有一个常见的习惯用法可以避免无意义的切片复制 gt gt gt a bytearray b hello gt gt gt b bytearray b goodbye cruel world gt gt gt a exte
  • sql-左连接-计数

    假设我有两张桌子 文章和评论 当我从文章表中选择列时 我还想在同一个选择语句中选择文章的评论数 假设这两个表之间的公共字段是articleid 我怎么做 我可以完成它 但我不知道我的方法是否有效 所以我想学习正确的方法 这应该更有效 因为分
  • 如何在android中显示所有共享选项?

    我正在开发一个 Android 应用程序 想通过打开所有设备中可用的共享选项 但目前该列表显示电子邮件 蓝牙 Gmail 和消息传递 BBC 新闻等其他应用程序在同一设备中显示了更多选项 如 Bump Picasa 等 如何显示所有可用选项
  • 在java中读取JSON对象[重复]

    这个问题在这里已经有答案了 我们如何在 JSP Servlet 或任何其他 Java 程序中读取 JSON 对象 我建议使用Gson http code google com p google gson 为了这 它的优点是对泛型的支持非常好
  • 即使首字母丢失,Elasticsearch 也会提供拼写检查建议

    我创建一个这样的索引 curl location request PUT http 127 0 0 1 9200 test header Content Type application json data raw settings num
  • 编译 Qt 库以在 Visual Studio 2008 上运行,为什么 nmake 失败?

    我正在尝试让我的 Visual Studio Qt 插件正常工作 因此为了重新编译 Qt 库 我从 VS 命令提示符运行了以下命令 c Qtfolder gt configure platform win32 msvc2008 之后我运行
  • Apple TestFlight:“此版本不再可用于测试”[关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 我一直在使用 TestFlight 进行内部 Beta 测试 一切都已设置完毕并且已经运行了一段时间 在提交的二进制文件之一被 AppSt
  • 在Python中使用有序字典作为对象字典

    我不知道为什么这不起作用 我正在使用odict http dev pocoo org hg sandbox raw file tip odict py班级来自PEP 372 http www python org dev peps pep
  • C# 加载二进制文件

    请告诉我最好 最快的方法 1 将非常小的二进制文件加载到内存中 例如图标 2 加载 读取大小为 512Mb 的非常大的二进制文件 3 当您不想考虑大小 速度而只需要做一件事时 您的常见选择 将所有字节读入内存 谢谢你 附 抱歉 也许是一个微
  • 检查JTA事务是否成功提交

    有没有办法检查当前事务是否在 JPA 实体侦听器中提交 如下所示 ApplicationScoped public class EntityListener Inject private Event
  • 如何从 JSON 回复中提取有意义的信息? [复制]

    这个问题在这里已经有答案了 回复 印度孟买 response version 0 1 termsofService http www wunderground com weather api d terms html features ge