I use robot framework at following environment.
- Python 2.7.6
- robotframework 2.8.7
- Ubuntu 14.04.3 LTS
I want to create json that include list. But Following script,Json.dumps interpret part as string.
*** Settings ***
Library Collections
Library json
Library String
*** Variables ***
${NAME} XXXX
${ID} YYYY
${PART_1} ZZZ1
${PART_2} ZZZ2
*** Test Cases ***
Test Create Json
${req_dict} Create Dictionary name=${NAME} id=${ID} part=[${PART_1},${PART_2}]
Log To Console *** Test Create Json Result ***
Log To Console ${req_json}
*** Keywords ***
Prepare Json Keyword
[Arguments] @{args}
${req_dict} Create Dictionary
:FOR ${pair} IN @{args}
\ ${key} ${value}= Split String ${pair} =
\ Set To Dictionary ${req_dict} ${key}=${value}
${req_json} Json.Dumps ${req_dict}
[Return] ${req_json}
This case,Robot shows
{"part": "[ZZZ1,ZZZ2]", "name": "XXXX", "id": "YYYY"}
But I want to create json like following.
{"part": ["ZZZ1","ZZZ2"], "name": "XXXX", "id": "YYYY"}
To interpret list, how can I change it ?