Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用Volley存储JSON对象_Java_Android_Json_Android Volley - Fatal编程技术网

Java 使用Volley存储JSON对象

Java 使用Volley存储JSON对象,java,android,json,android-volley,Java,Android,Json,Android Volley,这是我需要加载的JSON的结构 { "readme_0" : "THIS JSON IS THE RESULT OF YOUR SEARCH QUERY - THERE IS NO WEB PAGE WHICH SHOWS THE RESULT!", "readme_1" : "loklak.org is the framework for a message search system, not the portal, read: http://loklak.org/about.

这是我需要加载的JSON的结构

   {
  "readme_0" : "THIS JSON IS THE RESULT OF YOUR SEARCH QUERY - THERE IS NO WEB PAGE WHICH SHOWS THE RESULT!",
  "readme_1" : "loklak.org is the framework for a message search system, not the portal, read: http://loklak.org/about.html#notasearchportal",
  "readme_2" : "This is supposed to be the back-end of a search portal. For the api, see http://loklak.org/api.html",
  "readme_3" : "Parameters q=(query), source=(cache|backend|twitter|all), callback=p for jsonp, maximumRecords=(message count), minified=(true|false)",
  "search_metadata" : {
    "itemsPerPage" : "100",
    "count" : "100",
    "count_twitter_all" : 0,
    "count_twitter_new" : 100,
    "count_backend" : 0,
    "count_cache" : 78780,
    "hits" : 78780,
    "period" : 3066,
    "query" : "apple",
    "client" : "180.215.121.78",
    "time" : 5219,
    "servicereduction" : "false",
    "scraperInfo" : "http://45.55.245.191:9000,local"
  },
  "statuses" : [ {
    "created_at" : "2016-01-09T12:11:38.000Z",
    "screen_name" : "arifazmi92",
    "text" : "Perhaps I shouldn't have eaten that pisang goreng cheese perisa green apple. <img class=\"Emoji Emoji--forText\" src=\"https://abs.twimg.com/emoji/v2/72x72/1f605.png\" draggable=\"false\" alt=\"You could define a custom deserializer and register a type adapter with GSON. Also
why are you using this:

JsonArray jArray = parser.parse(Tempx.getString("GSON_FEED","")).getAsJsonArray();
{
“自述文件0”:“此JSON是您搜索查询的结果-没有显示结果的网页!”,
“自述文件1”:“loklak.org是邮件搜索系统的框架,而不是门户,内容如下:http://loklak.org/about.html#notasearchportal",
“自述文件2”:“这应该是搜索门户的后端。有关api,请参阅http://loklak.org/api.html",
“自述文件3”:“参数q=(查询),源=(缓存|后端|推特|全部),jsonp的回调=p,maximumRecords=(消息计数),minified=(真|假)”,
“搜索元数据”:{
“itemsPerPage”:“100”,
“计数”:“100”,
“count_twitter_all”:0,
“count_twitter_new”:100,
“计数后端”:0,
“计数缓存”:78780,
“热门”:78780,
“期间”:3066,
“查询”:“苹果”,
“客户”:“180.215.121.78”,
“时间”:5219,
“ServiceReduce”:“false”,
“scraperInfo”:http://45.55.245.191:9000,本地“
},
“状态”:[{
“创建时间”:“2016-01-09T12:11:38.000Z”,
“屏幕名称”:“arifazmi92”,

“text”:“也许我不该吃那个pisang goreng奶酪perisa绿苹果。您可以定义一个自定义反序列化程序并向GSON注册一个类型适配器。另外 你为什么要用这个:

public class FooDeserializer implements JsonDeserializer<Foos>
{
    @Override public Foos deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
    {
        JsonObject jsonObject = json.getAsJsonObject();
        JsonArray statusArray = jsonObject.get("statuses").getAsJsonArray();
        Foos result = new Foos();
        ArrayList fooArray = new ArrayList<>;
        for (JsonElement e : statusArray) {
            fooArray.add(new Foo());
        }
        result.setFoos(fooArray);
        return result;
    }
}
…当您打算使用GSON进行反序列化时?您可以在反序列化程序中进行

例如:

public类FooDeserializer实现JsonDeserializer
{
@重写公共Foos反序列化(JsonElement json,类型typeOfT,JsonDeserializationContext)引发JsonParseException
{
JsonObject JsonObject=json.getAsJsonObject();
JsonArray statusArray=jsonObject.get(“status”).getAsJsonArray();
Foos结果=新的Foos();
ArrayList fooArray=新的ArrayList;
对于(JsonElement e:statusArray){
添加(新的Foo());
}
result.setFoos(fooArray);
返回结果;
}
}

使用JSONObjectRequest。是的,我正在使用JSONObjectRequest,在这之前没有问题,因为我在SharedReference中获得JSON字符串,它的存储方式是:/I很麻烦Dplz提供关于JSONObjectRequest的代码。
JSONObjectRequest TweetReq=new JSONObjectRequest(Request.Method.get,URL1,null,new Response.Listener(){
您遇到了哪一个错误?有没有实现相同的示例?有一个链接显示了更多内容。您需要向Gson实例注册一个类型适配器。我遇到了以下问题,是否有更简单的方法来存储此:(?