简体   繁体   中英

Gson.toJson() method returns string embedded with "data"

I am working on Workfusion which is one of the automation tool and it consists of selenium, java and Web -harvest technology. Below is the snipped of my code.

  <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>

In map Key is "ship to ctry cd" and Value is "AT" but after converting toJson String it gives as below. I dont need this data word i need normal Json Value.

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

you can do :

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

to achieve that

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM