【问题标题】:Gson.toJson() method returns string embedded with "data"Gson.toJson() 方法返回嵌入“数据”的字符串
【发布时间】:2020-01-14 14:42:04
【问题描述】:

我正在开发 Workfusion,它是自动化工具之一,它由 selenium、java 和 Web 收获技术组成。 下面是我的代码的片段。

  <while condition="${continue_flg}" maxloops="${full_data.size()-1}"
          index="ind">
          <script><![CDATA[
                 import com.google.gson.Gson;
                 Gson gson = new Gson();
                 LinkedHashMap recMapTemp1 = full_data[ind.toInt()];
                 println "*****"+recMapTemp1; // Contains key value map
                 jsonValueMap = gson.toJson(recMapTemp1);
                 println "*****"+jsonValueMap; // "data" is added before value
          ]]></script>

          <insert-datastore datastore-name="Fallout_type"
                 json-value-map="${jsonValueMap}" create="true" />
   </while>

在地图中,键是“运送到 ctry cd”,值是“AT”,但在转换为 JSON 字符串后,它给出如下。 我不需要这个数据字我需要正常的 Json 值。

"ship to ctry cd":{"data":"AT"},

【问题讨论】:

    标签: java string gson webharvest


    【解决方案1】:

    你可以这样做:

    println "*****"+jsonValueMap.data; 
    

    实现这一目标

    【讨论】:

    • 我想要 Json 字符串作为这个 "ship to ctry cd":"AT"
    猜你喜欢
    • 1970-01-01
    • 2015-06-09
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 2020-04-13
    • 2023-03-30
    • 2014-03-04
    相关资源
    最近更新 更多