Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.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 如何将html数据转换为json对象?_Java_Android_Html_Json - Fatal编程技术网

Java 如何将html数据转换为json对象?

Java 如何将html数据转换为json对象?,java,android,html,json,Java,Android,Html,Json,我想理解从html到JSON对象 有人能告诉我写这篇文章的规则吗,或者给我提供一些指导吗? 如何将html数据转换为json对象? 我尝试使用html url从每日运动下载 protected void onPostExecute(String output) { super.onPostExecute(output); html = output; imagelist.add(getRegexBack(html, "property=

我想理解从html到JSON对象

有人能告诉我写这篇文章的规则吗,或者给我提供一些指导吗?

如何将html数据转换为json对象?

我尝试使用html url从每日运动下载

    protected void onPostExecute(String output) {
        super.onPostExecute(output);

        html = output;

        imagelist.add(getRegexBack(html, "property=\"og:image\" content=\"([^\"]+)\""));
        desc = getRegexBack(html, "property=\"og:description\" content=\"([^\"]+)\"");

        String sJs = getRegexBack(html , "\"qualities\":((.+?))\\}\\]\\}");

        if(!sJs.isEmpty()){sJs = sJs+"}]}";}

        try {

            JSONObject json = new JSONObject(sJs);

            for(int i=0; i < json.length(); i++){

                for(int o=0; o <  json.getJSONArray(json.names().get(i).toString()).length() ; o++){

                    String VIDEO = json.getJSONArray(json.names().get(i).toString()).getJSONObject(o).getString("url");

                    if(VIDEO.contains(".mp4")){

                        videolist.add(VIDEO);
                    }
                }

            }

        } catch (JSONException e) {e.getStackTrace();
        }

        if(videolist.size() == 0){
            videolist = getRegexBackArray(xmlCharacterConverter(html), "\"(http([^\\s\"]+)?\\.mp4([^\\s\"]+)?)\"");
            for(int v=0; v < videolist.size() ; v++){
                videolist.set(v , videolist.get(v).replace("\\" , ""));
            }
        }

        if(active){
            if(counter != 5){
                counter++;
            }
            mDialogAdvance();
        }else{
            mDialog = true;
        }
    }[
受保护的void onPostExecute(字符串输出){
super.onPostExecute(输出);
html=输出;
add(getRegexBack(html,“属性=\”og:image\“内容=\”([^\“]+)\”));
desc=getRegexBack(html,“属性=\”og:description\“内容=\”([^\“]+)\”);
字符串sJs=getRegexBack(html,“\”质量\“:((.+?)\\}\\\\]\}”);
如果(!sJs.isEmpty()){sJs=sJs+“}]}”;}
试一试{
JSONObject json=新的JSONObject(sJs);
for(int i=0;i

你问过作者吗?为什么要同时标记java和javascript?这是java代码。欢迎使用Stack Overflow!现在你的问题还不清楚你想实现什么或你的问题是什么。请编辑你的问题以使其更容易理解。首先,向我们解释你想做什么。其次,详细说明你想做什么到目前为止,你已经达到了这个目标。第三,向我们解释你在哪里陷入困境以及问题的原因。你的问题越容易理解,你得到答案的速度就越快。