MCPcopy Create free account
hub / github.com/geekcomputers/Python / convert_python_to_json

Method convert_python_to_json

JsonParser.py:19–32  ·  view source on GitHub ↗

this function converts dictionary of data to json string and store it in json file if json file pass provided if not it only returns the json string args: par_data_dic: dictionary of data par_json_file: the output json file return: json stri

(self, par_data_dic, par_json_file="")

Source from the content-addressed store, hash-verified

17 return data_dic
18
19 def convert_python_to_json(self, par_data_dic, par_json_file=""):
20 """
21 this function converts dictionary of data to json string and store it in json file if
22 json file pass provided if not it only returns the json string
23 args:
24 par_data_dic: dictionary of data
25 par_json_file: the output json file
26 return: json string
27 """
28 if par_json_file:
29 with open(par_json_file, "w") as outfile:
30 return json.dump(par_data_dic, outfile)
31 else:
32 return json.dump(par_data_dic)
33
34 def get_json_value(self, par_value, par_json_file):
35 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected