在 REST Web 服务中,POST JSON 正文如下所示:
{
"printRequest" : {
"printName" : "XYZ",
"enable" : "truee",
"printerDescription" : "anyString",
"connectionString" : "YYYY",
"ABC" : "XXX"
}
}
这里属性enable
是 boolean 类型,但在“true”中多了一个“e”。如何将其反序列化为纯 Java boolean 值?
最佳答案
JSON支持真实 boolean 值:
true
false
请注意,没有引号。 “true”
不是 JSON boolean 值,而是 JSON 字符串。
帮自己一个忙,让客户发送此信息:
{
"printRequest": {
"printName": "XYZ",
"enable": true,
"printerDescription": "anyString",
"connectionString": "YYYY",
"ABC": "XXX"
}
}
关于java - Rest Web 服务 JSON 请求正文,其中 "truee"作为 boolean 真值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34161005/