Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
arraylist to json
#1
look for help for the below:
i have list of item in array;
for row  in rows:
        t=(row[0])
        rowarray_list.append(t)
when convert to key value
j_string=','.join(rowarray_list)
j=json.dumps({"_meta":{ "hostvars":{}},"instances":{"hosts":[j_string],"vars":{}}})
it give me
{"_meta": {"hostvars": {}}, "instances": {"hosts": ["abc,efg"], "vars": {}}}
instead
{"_meta": {"hostvars": {}}, "instances": {"hosts": ["abc","efg"], "vars": {}}}
Thanks in advance
Larz60+ write Aug-23-2021, 10:01 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply


Messages In This Thread
arraylist to json - by soonyu - Aug-23-2021, 05:15 PM
RE: arraylist to json - by soonyu - Aug-23-2021, 05:26 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020