欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

遇到com.google.gson.internal.LinkedTreeMap  

程序员文章站 2024-03-15 13:31:59
...
{   "code" : 0,   "data" : [      {         "hls_url" : "http://tv.kkitv.com:8880/live/32/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 08:53:25",         "media_ffmpeg" : "0",         "media_id" : "32",         "media_input_network" : "eth0",         "media_input_url" : "rtmp://live.hkstv.hk.lxdns.com/live/hks",         "media_name" : "hks",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "94",         "online" : true,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/32?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/33/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:51",         "media_ffmpeg" : "0",         "media_id" : "33",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.54:10392",         "media_name" : "CCTV-1",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "69",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/33?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/34/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:51",         "media_ffmpeg" : "0",         "media_id" : "34",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.2:10006",         "media_name" : "CCTV-2",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "38",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/34?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/35/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:51",         "media_ffmpeg" : "0",         "media_id" : "35",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.141:10864",         "media_name" : "CCTV-3",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "12",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/35?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/36/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:52",         "media_ffmpeg" : "0",         "media_id" : "36",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.3:10380",         "media_name" : "CCTV-4",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "20",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/36?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/37/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:52",         "media_ffmpeg" : "0",         "media_id" : "37",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.142:10870",         "media_name" : "CCTV-5",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "7",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/37?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/38/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:52",         "media_ffmpeg" : "0",         "media_id" : "38",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.143:10876",         "media_name" : "CCTV-6",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "6",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/38?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/39/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:52",         "media_ffmpeg" : "0",         "media_id" : "39",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.4:10018",         "media_name" : "CCTV-7",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "9",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/39?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/40/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 09:34:52",         "media_ffmpeg" : "0",         "media_id" : "40",         "media_input_network" : "eth1",         "media_input_url" : "rtp://225.1.2.144:10882",         "media_name" : "CCTV-8",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "2",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/40?vhost=__defaultVhost__"      },      {         "hls_url" : "http://tv.kkitv.com:8880/live/65/hls.m3u8?vhost=__defaultVhost__",         "media_create_stamp" : "1998-01-25 10:06:40",         "media_ffmpeg" : "0",         "media_id" : "65",         "media_input_network" : "eth1",         "media_input_url" : "udp://@239.154.100.1:1234",         "media_name" : "多节目流(4套)",         "media_output_network" : "",         "media_output_url" : "",         "media_played_count" : "18",         "online" : false,         "rtsp_url" : "rtsp://ae59542d-b0c3-432d-bb33-485a625d223d:3@tv.kkitv.com:554/live/65?vhost=__defaultVhost__"      }   ]}



package com.frame.bean;

public class ReturnApiJSON<T> {

	private int code;
	
	private T data;
	
	private String msg;
	
	

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}
	
	
}



c出现com.google.gson.internal.LinkedTreeMap cannot be cast to MediaVO

在写入的时候用

new TypeToken<ReturnApiJSON<List<MediaVO>>>(){}.getType()

类型即可