• Android为TV端助力之解析序列话的JSON


    解析json时报错default constructor not found. class.............

    比如


    public class MediaRepBean implements Parcelable {

    /**
    * id : 11852
    * name : {"zh_CN":null,"en_US":null,"THIRD":null}
    * sequence : 0
    * cpobjectcode : 000208684474143085324
    * mediaType : null
    * duration : 4380
    * videoType : null
    * audioType : null
    * streamType : null
    * filePath :
    * fileSize : 0
    * subtitle :
    * sid : 1
    */

    public int id;
    public Map<String,String> name;
    public int sequence;
    public String cpobjectcode;
    public Object mediaType;
    public int duration;
    public Object videoType;
    public Object audioType;
    public Object streamType;
    public String filePath;
    public int fileSize;
    public String subtitle;
    public int sid;

    public MediaRepBean() {
    }

    protected MediaRepBean(Parcel in) {
    id = in.readInt();
    name = in.readHashMap(HashMap.class.getClassLoader());
    sequence = in.readInt();
    cpobjectcode = in.readString();
    mediaType = in.readString();
    duration = in.readInt();
    videoType = in.readString();
    audioType = in.readString();
    streamType = in.readString();
    filePath = in.readString();
    fileSize = in.readInt();
    subtitle = in.readString();
    sid = in.readInt();

    }

    public static final Creator<MediaRepBean> CREATOR = new Creator<MediaRepBean>() {
    @Override
    public MediaRepBean createFromParcel(Parcel in) {
    return new MediaRepBean(in);
    }

    @Override
    public MediaRepBean[] newArray(int size) {
    return new MediaRepBean[size];
    }
    };

    @Override
    public int describeContents() {
    return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(id);
    dest.writeMap(name);
    dest.writeInt(sequence);
    dest.writeString(cpobjectcode);
    dest.writeString(mediaType);
    dest.writeInt(duration);
    dest.writeString(videoType);
    dest.writeString(audioType);
    dest.writeString(streamType);
    dest.writeString(filePath);
    dest.writeInt(fileSize);
    dest.writeString(subtitle);
    dest.writeInt(sid);

    }
    }
    必须加一个空的构造函数,不然会解析失败
  • 相关阅读:
    【转】MyEclipse项目的字符编码设置
    【转】VS2008中 ATL CLR MFC Win32 区别
    【转】字符数组与字符指针
    【转】How to: Convert Between Various String Types
    【转】ATL基础BSTR CComBSTR SysAllocString
    【转】PHP ini_set ini_get 可操作配置参数列表
    【转】字符、字符数组、char、string的区别分析
    【转】PHP 计算页面执行时间
    【转】Java 如何判断String为空?
    【转】Converting char array to BSTR
  • 原文地址:https://www.cnblogs.com/xiaoxiaing/p/11143044.html
Copyright © 2020-2023  润新知