【问题标题】:How do I fix this json query?如何修复这个 json 查询?
【发布时间】:2015-08-20 19:00:31
【问题描述】:

我正在尝试修复我的 json 查询,但每次我在 json 解析器验证器中复制粘贴时,它都会显示它不正确,但我很难理解我缺少什么,因为我是新手。任何线索我错过了什么? 这是我的查询请求:

 private final static String QUERY_UPDATE = "\"E\": \"Update\","
            +     "\"W\": '{'"
            +       "\"Pages\": \"{0}\""
            +     "'}'";

以及相应的调用:

 public static String getUpdate(String code) {
        return ComposerUtils.getSimpleQuery(MessageFormat.format(QUERY_UPDATE, new Object[] {
                code
        }));
    }

这是我看到的发送请求:

{  "Entity": { "E": "Update","W": {"Pages": "[{"PageCode":"SP_PAGE_001","IsSelected":"true"},{"PageCode":"SP_PAGE_058","IsSelected":"true"},{"PageCode":"SP_PAGE_014","IsSelected":"true"},{"PageCode":"SP_PAGE_006","IsSelected":"true"},{"PageCode":"SP_PAGE_036"},{"PageCode":"SP_PAGE_012"},{"PageCode":"SP_PAGE_017"},{"PageCode":"SP_PAGE_039"},{"PageCode":"SP_PAGE_009"},{"PageCode":"SP_PAGE_002"},{"PageCode":"SP_PAGE_003"},{"PageCode":"SP_PAGE_004"},{"PageCode":"SP_PAGE_010"},{"PageCode":"SP_PAGE_008"},{"PageCode":"SP_PAGE_028"},{"PageCode":"SP_PAGE_027"},{"PageCode":"SP_PAGE_378"},{"PageCode":"SP_PAGE_060"},{"PageCode":"SP_PAGE_061"},{"PageCode":"SP_PAGE_062"},{"PageCode":"SP_PAGE_064"},{"PageCode":"SP_PAGE_063"},{"PageCode":"SP_PAGE_032"},{"PageCode":"SP_PAGE_023"},{"PageCode":"SP_PAGE_016"},{"PageCode":"SP_PAGE_015"},{"PageCode":"SP_PAGE_660"},{"PageCode":"SP_PAGE_024"},{"PageCode":"SP_PAGE_021"},{"PageCode":"SP_PAGE_031"},{"PageCode":"SP_PAGE_026"},{"PageCode":"SP_PAGE_025"},{"PageCode":"SP_PAGE_019"},{"PageCode":"SP_PAGE_038"},{"PageCode":"SP_PAGE_053"},{"PageCode":"SP_PAGE_033"},{"PageCode":"SP_PAGE_068"},{"PageCode":"SP_PAGE_069"},{"PageCode":"SP_PAGE_497"},{"PageCode":"SP_PAGE_007"},{"PageCode":"SP_PAGE_022"},{"PageCode":"SP_PAGE_035","IsSelected":"true"}]"}}}

【问题讨论】:

  • 尝试将生成的 JSON 字符串粘贴到 jsonlint.com - 它会给出详细错误

标签: android json getjson jsonpath jsonresponse


【解决方案1】:

设置 JSON 数组时不需要引号:

“页数”:“[.....]”

应该是

“页数”:[ .... ]

【讨论】:

  • 你能告诉我关于私有最终静态字符串 QUERY_UPDATE = "\"E\": \"Update\"," + "\"W\": '{'" + "\ "页数\": \"{0}\"" + "'}'";
  • 你能不能试试:private final static String QUERY_UPDATE = "\"E\": \"Update\"," + "\"W\": '{'" + "\"Pages \": {0}" + "'}'";
  • 很高兴我能帮上忙 :)
猜你喜欢
  • 2021-07-08
  • 1970-01-01
  • 1970-01-01
  • 2010-10-10
  • 1970-01-01
  • 1970-01-01
  • 2021-07-03
  • 2021-03-12
  • 1970-01-01
相关资源
最近更新 更多