0

I have 2 different arrays:

dataList = ['a_cout', 'b_count', 'c_count']
dataList1 = [15404, 21381, 3]

I am trying to merge them into a json object as Key-Value pair like :

'{
  "a_count" : 15401,
  "b_count" : 21381,
  "c_count" : 3
 }'

I am using json lib in Python 2.x

0

1 Answer 1

3

You can get those lists into a dictionary with a comprehension, then jsonify the dictionary:

import json 
mydict = {k:v for k,v in zip(dataList,dataList1)}
jdict = json.dumps(mydict)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.