- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 json,它有一个被视为字符串的标签,尽管该字符串也是 json 格式。
{
"details": "{\"max_keep_days\":\"\",\"notes\":\"\",\"dir\":\"\",\"auto_host_enable\":\"1\",\"auto_host\":\"https://videos3.earthcam.com/fecnetwork/9189.flv/playlist.m3u8\",\"rtsp_transport\":\"tcp\",\"muser\":\"\",\"mpass\":\"\",\"port_force\":\"0\",\"fatal_max\":\"0\",\"skip_ping\":null,\"is_onvif\":null,\"onvif_port\":\"\",\"aduration\":\"1000000\",\"probesize\":\"1000000\",\"stream_loop\":\"0\",\"sfps\":\"\",\"accelerator\":\"0\",\"hwaccel\":\"auto\",\"hwaccel_vcodec\":\"\",\"hwaccel_device\":\"\",\"stream_type\":\"mp4\",\"stream_flv_type\":\"ws\",\"stream_flv_maxLatency\":\"\",\"stream_mjpeg_clients\":\"\",\"stream_vcodec\":\"copy\",\"stream_acodec\":\"no\",\"hls_time\":\"2\",\"hls_list_size\":\"3\",\"preset_stream\":\"ultrafast\",\"signal_check\":\"10\",\"signal_check_log\":\"0\",\"stream_quality\":\"15\",\"stream_fps\":\"2\",\"stream_scale_x\":\"\",\"stream_scale_y\":\"\",\"rotate_stream\":\"no\",\"svf\":\"\",\"tv_channel\":\"0\",\"tv_channel_id\":\"\",\"tv_channel_group_title\":\"\",\"stream_timestamp\":\"0\",\"stream_timestamp_font\":\"\",\"stream_timestamp_font_size\":\"\",\"stream_timestamp_color\":\"\",\"stream_timestamp_box_color\":\"\",\"stream_timestamp_x\":\"\",\"stream_timestamp_y\":\"\",\"stream_watermark\":\"0\",\"stream_watermark_location\":\"\",\"stream_watermark_position\":\"tr\",\"snap\":\"0\",\"snap_fps\":\"\",\"snap_scale_x\":\"\",\"snap_scale_y\":\"\",\"snap_vf\":\"\",\"vcodec\":\"copy\",\"crf\":\"1\",\"preset_record\":\"\",\"acodec\":\"no\",\"dqf\":\"0\",\"cutoff\":\"15\",\"rotate_record\":\"no\",\"vf\":\"\",\"timestamp\":\"0\",\"timestamp_font\":\"\",\"timestamp_font_size\":\"10\",\"timestamp_color\":\"white\",\"timestamp_box_color\":\"0x00000000@1\",\"timestamp_x\":\"(w-tw)/2\",\"timestamp_y\":\"0\",\"watermark\":\"0\",\"watermark_location\":\"\",\"watermark_position\":\"tr\",\"cust_input\":\"\",\"cust_snap\":\"\",\"cust_rtmp\":\"\",\"cust_rawh264\":\"\",\"cust_detect\":\"\",\"cust_stream\":\"\",\"cust_stream_server\":\"\",\"cust_record\":\"\",\"custom_output\":\"\",\"detector\":\"0\",\"detector_send_frames\":\"1\",\"detector_lock_timeout\":\"\",\"detector_save\":\"0\",\"detector_fps\":\"\",\"detector_scale_x\":\"640\",\"detector_scale_y\":\"480\",\"detector_record_method\":\"sip\",\"detector_trigger\":\"1\",\"detector_trigger_record_fps\":\"\",\"detector_timeout\":\"10\",\"watchdog_reset\":\"0\",\"detector_delete_motionless_videos\":\"0\",\"detector_webhook\":\"0\",\"detector_webhook_url\":\"\",\"detector_command_enable\":\"0\",\"detector_command\":\"\",\"detector_command_timeout\":\"\",\"detector_mail\":\"0\",\"detector_mail_send_video\":null,\"detector_mail_timeout\":\"\",\"detector_discordbot\":null,\"detector_discordbot_send_video\":null,\"detector_discordbot_timeout\":\"\",\"use_detector_filters\":null,\"use_detector_filters_object\":null,\"cords\":\"[]\",\"detector_filters\":\"\",\"detector_pam\":\"1\",\"detector_show_matrix\":null,\"detector_sensitivity\":\"\",\"detector_max_sensitivity\":\"\",\"detector_threshold\":\"1\",\"detector_color_threshold\":\"\",\"detector_frame\":\"0\",\"detector_noise_filter\":null,\"detector_noise_filter_range\":\"\",\"detector_notrigger\":\"0\",\"detector_notrigger_mail\":\"0\",\"detector_notrigger_timeout\":\"\",\"detector_use_detect_object\":\"0\",\"detector_use_motion\":\"1\",\"detector_fps_object\":\"\",\"detector_scale_x_object\":\"\",\"detector_scale_y_object\":\"\",\"detector_lisence_plate\":\"0\",\"detector_lisence_plate_country\":\"us\",\"detector_buffer_vcodec\":\"auto\",\"detector_buffer_acodec\":null,\"detector_buffer_fps\":\"\",\"detector_buffer_hls_time\":\"\",\"detector_buffer_hls_list_size\":\"\",\"detector_buffer_start_number\":\"\",\"detector_buffer_live_start_index\":\"\",\"control\":\"0\",\"control_base_url\":\"\",\"control_url_method\":null,\"control_digest_auth\":null,\"control_stop\":\"0\",\"control_url_stop_timeout\":\"\",\"control_url_center\":\"\",\"control_url_left\":\"\",\"control_url_left_stop\":\"\",\"control_url_right\":\"\"\"control_url_right_stop\":\"\",\"control_url_up\":\"\",\"control_url_up_stop\":\"\",\"control_url_down\":\"\",\"control_url_down_stop\":\"\",\"control_url_enable_nv\":\"\",\"control_url_disable_nv\":\"\",\"control_url_zoom_out\":\"\",\"control_url_zoom_out_stop\":\"\",\"control_url_zoom_in\":\"\",\"control_url_zoom_in_stop\":\"\",\"groups\":\"[]\",\"loglevel\":\"warning\",\"sqllog\":\"0\",\"detector_cascades\":\"\",\"stream_channels\":\"\",\"input_maps\":\"\",\"input_map_choices\":\"\"}"
}
我认为这可能与改造没有直接关系。可能更像 jackson ,但有没有办法通过改造来实现反序列化。
我已经为上述细节创建了一个 POJO。我不得不删除一些属性,因为它太大而无法在此处发布。
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"max_keep_days",
"notes",
"dir",
"auto_host_enable",
"auto_host",
"rtsp_transport",
"muser",
"mpass",
"port_force"
})
public class Details implements Serializable
{
@JsonProperty("max_keep_days")
private String max_keep_days;
@JsonProperty("notes")
private String notes;
@JsonProperty("dir")
private String dir;
@JsonProperty("auto_host_enable")
private String auto_host_enable;
@JsonProperty("auto_host")
private String auto_host;
@JsonProperty("rtsp_transport")
private String rtsp_transport;
@JsonProperty("muser")
private String muser;
@JsonProperty("mpass")
private String mpass;
@JsonProperty("port_force")
private String port_force;
private final static long serialVersionUID = 4253775945877731727L;
@JsonProperty("max_keep_days")
public String getMax_keep_days() {
return max_keep_days;
}
@JsonProperty("max_keep_days")
public void setMax_keep_days(String max_keep_days) {
this.max_keep_days = max_keep_days;
}
@JsonProperty("notes")
public String getNotes() {
return notes;
}
@JsonProperty("notes")
public void setNotes(String notes) {
this.notes = notes;
}
@JsonProperty("dir")
public String getDir() {
return dir;
}
@JsonProperty("dir")
public void setDir(String dir) {
this.dir = dir;
}
@JsonProperty("auto_host_enable")
public String getAuto_host_enable() {
return auto_host_enable;
}
@JsonProperty("auto_host_enable")
public void setAuto_host_enable(String auto_host_enable) {
this.auto_host_enable = auto_host_enable;
}
@JsonProperty("auto_host")
public String getAuto_host() {
return auto_host;
}
@JsonProperty("auto_host")
public void setAuto_host(String auto_host) {
this.auto_host = auto_host;
}
@JsonProperty("rtsp_transport")
public String getRtsp_transport() {
return rtsp_transport;
}
@JsonProperty("rtsp_transport")
public void setRtsp_transport(String rtsp_transport) {
this.rtsp_transport = rtsp_transport;
}
@JsonProperty("muser")
public String getMuser() {
return muser;
}
@JsonProperty("muser")
public void setMuser(String muser) {
this.muser = muser;
}
@JsonProperty("mpass")
public String getMpass() {
return mpass;
}
@JsonProperty("mpass")
public void setMpass(String mpass) {
this.mpass = mpass;
}
@JsonProperty("port_force")
public String getPort_force() {
return port_force;
}
@JsonProperty("port_force")
public void setPort_force(String port_force) {
this.port_force = port_force;
}
}
但我仍然得到错误。以下是我的使用方法。
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.io.Serializable;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"mid",
"ke",
"name",
"shto",
"shfr",
"details",
"type",
"ext",
"protocol",
"host",
"path",
"port",
"fps",
"mode",
"width",
"height",
"currentlyWatching",
"currentCpuUsage",
"status",
"streams",
"streamsSortedByType"
})
@JsonIgnoreProperties(ignoreUnknown = true)
public class Monitor implements Serializable {
@JsonProperty("mid")
private String mid;
@JsonProperty("ke")
private String ke;
@JsonProperty("name")
private String name;
@JsonProperty("shto")
private String shto;
@JsonProperty("shfr")
private String shfr;
@JsonProperty("details")
private Details details;
@JsonProperty("type")
private String type;
@JsonProperty("ext")
private String ext;
@JsonProperty("protocol")
private String protocol;
@JsonProperty("host")
private String host;
@JsonProperty("path")
private String path;
@JsonProperty("port")
private Long port;
@JsonProperty("fps")
private Long fps;
@JsonProperty("mode")
private String mode;
@JsonProperty("width")
private Long width;
@JsonProperty("height")
private Long height;
@JsonProperty("currentlyWatching")
private Long currentlyWatching;
@JsonProperty("currentCpuUsage")
private Float currentCpuUsage;
@JsonProperty("status")
private String status;
@JsonProperty("snapshot")
private String snapshot;
@JsonProperty("streams")
private List<String> streams = null;
@JsonProperty("streamsSortedByType")
private StreamsSortedByType streamsSortedByType;
private final static long serialVersionUID = -7389140931424648308L;
@JsonProperty("mid")
public String getMid() {
return mid;
}
@JsonProperty("mid")
public void setMid(String mid) {
this.mid = mid;
}
@JsonProperty("ke")
public String getKe() {
return ke;
}
@JsonProperty("ke")
public void setKe(String ke) {
this.ke = ke;
}
@JsonProperty("name")
public String getName() {
return name;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("shto")
public String getShto() {
return shto;
}
@JsonProperty("shto")
public void setShto(String shto) {
this.shto = shto;
}
@JsonProperty("shfr")
public String getShfr() {
return shfr;
}
@JsonProperty("shfr")
public void setShfr(String shfr) {
this.shfr = shfr;
}
@JsonProperty("details")
public Details getDetails() {
return details;
}
@JsonProperty("details")
public void setDetails(Details details) {
this.details = details;
}
@JsonProperty("type")
public String getType() {
return type;
}
@JsonProperty("type")
public void setType(String type) {
this.type = type;
}
@JsonProperty("ext")
public String getExt() {
return ext;
}
@JsonProperty("ext")
public void setExt(String ext) {
this.ext = ext;
}
@JsonProperty("protocol")
public String getProtocol() {
return protocol;
}
@JsonProperty("protocol")
public void setProtocol(String protocol) {
this.protocol = protocol;
}
@JsonProperty("host")
public String getHost() {
return host;
}
@JsonProperty("host")
public void setHost(String host) {
this.host = host;
}
@JsonProperty("path")
public String getPath() {
return path;
}
@JsonProperty("path")
public void setPath(String path) {
this.path = path;
}
@JsonProperty("port")
public Long getPort() {
return port;
}
@JsonProperty("port")
public void setPort(Long port) {
this.port = port;
}
@JsonProperty("fps")
public Long getFps() {
return fps;
}
@JsonProperty("fps")
public void setFps(Long fps) {
this.fps = fps;
}
@JsonProperty("mode")
public String getMode() {
return mode;
}
@JsonProperty("mode")
public void setMode(String mode) {
this.mode = mode;
}
@JsonProperty("width")
public Long getWidth() {
return width;
}
@JsonProperty("width")
public void setWidth(Long width) {
this.width = width;
}
@JsonProperty("height")
public Long getHeight() {
return height;
}
@JsonProperty("height")
public void setHeight(Long height) {
this.height = height;
}
@JsonProperty("currentlyWatching")
public Long getCurrentlyWatching() {
return currentlyWatching;
}
@JsonProperty("currentlyWatching")
public void setCurrentlyWatching(Long currentlyWatching) {
this.currentlyWatching = currentlyWatching;
}
@JsonProperty("currentCpuUsage")
public Float getCurrentCpuUsage() {
return currentCpuUsage;
}
@JsonProperty("currentCpuUsage")
public void setCurrentCpuUsage(Float currentCpuUsage) {
this.currentCpuUsage = currentCpuUsage;
}
@JsonProperty("status")
public String getStatus() {
return status;
}
@JsonProperty("status")
public void setStatus(String status) {
this.status = status;
}
@JsonProperty("snapshot")
public String getSnapshot() {
return snapshot;
}
@JsonProperty("snapshot")
public void setSnapshot(String snapshot) {
this.snapshot = snapshot;
}
@JsonProperty("streams")
public List<String> getStreams() {
return streams;
}
@JsonProperty("streams")
public void setStreams(List<String> streams) {
this.streams = streams;
}
@JsonProperty("streamsSortedByType")
public StreamsSortedByType getStreamsSortedByType() {
return streamsSortedByType;
}
@JsonProperty("streamsSortedByType")
public void setStreamsSortedByType(StreamsSortedByType streamsSortedByType) {
this.streamsSortedByType = streamsSortedByType;
}
}
感谢任何反馈。
最佳答案
从 Jackson 的角度来看,Json 中的字段 details
只是一个字符串,即使它恰好是转义为字符串的某个实例的 Json 表示。
错误实际上是说 Jackson 不知道如何将此字符串转换为 Details 实例。幸运的是,这个问题很容易通过添加 JsonCreater 来解决,因此通过在 Details
类中实现一个方法,将这个字符串转换为 Details
的实例:
@JsonCreator
public static Details createDetail(String s) throws IOException {
return new ObjectMapper().readValue(s, Details.class);
}
这只是告诉 Jackson 在它需要 Json 表示细节时获取字符串时使用此方法。
注意:如果您不使用类似的东西:
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,
false);
你接下来会碰到那里:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException
因为字符串包含您的 Details
类不包含的属性。
关于Android - 使用 Retrofit 获取错误 "Cannot construct instance of (although at least one create exist)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54058360/
我在 SQL 查询中使用了一个简单的 IF NOT EXISTS/WHERE NOT EXISTS 语句(我都尝试过),但我总是收到 mysql 错误,不知道为什么。尝试使用不同的引号,检查我的 My
我有 2 个表:tbl1 和 tbl2。我想从 tbl1 返回一行,其中包含以下列:col1、col2、col3、can_be_deleted 、有重要项目。这个想法是,can_be_deleted
如果您是 "t1".persona_1_id = 2,则预期结果应返回 persona_id = 4。 like --- id persona_1_id persona_2_id liked 1 2
我遇到了这个用于执行幂等插入的 github SQL 代码示例。完全按照我想要的方式工作。我不想使用 EXISTS,因为我觉得它有点困惑。可以使用联接对相同的操作进行编码吗? 下面是我在 github
public bool CheckTblExist(string TblName) { try { string cmTxt = "s
表1 Id Name DemoID 1 a 33 2 b 44 3 c 33 4 d 33 5 e 44 表2 Id DemoID IsT
我对 SQL 非常陌生。我想知道当我使用“IF EXISTS”或“IF NOT EXISTS”时会发生什么。例如:以下两个语句有什么区别: 语句 1:(存在) IF EXISTS( SELECT OR
我正在更新 exist-db 集合中的 XML 文件,我必须检查是否存在 id 以决定是否必须在我的文档中替换或插入某些内容。 我注意到随着文件的增长,查询执行时间显着恶化,我决定为我的文件添加一个索
我有一个正在尝试更新的数据库,但我不明白为什么会收到有关不存在的列的奇怪错误。当我使用“heroku pg:psql”访问数据库时,我完全可以看到该列。我找到了couple其他questions遇到类
我有一个这样的查询 SELECT ... FROM ... WHERE (SELECT EXISTS (SELECT...)) which did not return anything th
我有一个可以对数据库执行插入和更新的程序,我从 API 获取数据。这是我得到的示例数据: $uname = $get['userName']; $oname = $get['offerNa
我的批处理文件中有这个脚本 -- if not exist "%JAVA_HOME%" ( echo JAVA_HOME '%JAVA_HOME%' path doesn't exist) -
有没有办法让 Directory.Exists/File.Existssince 区分大小写 Directory.Exists(folderPath) 和 Directory.Exists(folde
考虑使用这两个表和以下查询: SELECT Product. * FROM Product WHERE EXISTS ( SELECT * FROM Codes
我正在使用 Subclipse 1.6.18 使用 Eclipse 3.72 (Indigo) 来处理 SVN 1.6 存储库。这一切都在 Ubuntu 下运行。 我有一个项目,在我更新我的 Ecli
我正在尝试使用 Terraform 配置 Azure 存储帐户和文件共享: resource "random_pet" "prefix" {} provider "azurerm" { versi
我有兴趣为需要使用 NOT EXISTS 的应用程序编写查询。子句来检查一行是否存在。 我正在使用 Sybase,但我想知道一般 SQL 中是否有一个示例,您可以在其中编写具有 NOT EXISTS
我正在尝试使用 Terraform 配置 Azure 存储帐户和文件共享: resource "random_pet" "prefix" {} provider "azurerm" { versi
下面是代码示例: CREATE TABLE #titles( title_id varchar(20), title varchar(80)
我曾经这样编写 EXISTS 检查: IF EXISTS (SELECT * FROM TABLE WHERE Columns=@Filters) BEGIN UPDATE TABLE SET
我是一名优秀的程序员,十分优秀!