MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / to_json

Method to_json

functional/pipeline.py:1542–1556  ·  view source on GitHub ↗

Saves the sequence to a json file. If root_array is True, then the sequence will be written to json with an array at the root. If it is False, then the sequence will be converted from a sequence of (Key, Value) pairs to a dictionary so that the json root is a dictionary.

(self, path, root_array=True, mode=WRITE_MODE, compression=None)

Source from the content-addressed store, hash-verified

1540 )
1541
1542 def to_json(self, path, root_array=True, mode=WRITE_MODE, compression=None):
1543 """
1544 Saves the sequence to a json file. If root_array is True, then the sequence will be written
1545 to json with an array at the root. If it is False, then the sequence will be converted from
1546 a sequence of (Key, Value) pairs to a dictionary so that the json root is a dictionary.
1547
1548 :param path: path to write file
1549 :param root_array: write json root as an array or dictionary
1550 :param mode: file open mode
1551 """
1552 with universal_write_open(path, mode=mode, compression=compression) as output:
1553 if root_array:
1554 json.dump(self.to_list(), output)
1555 else:
1556 json.dump(self.to_dict(), output)
1557
1558 def to_csv(
1559 self,

Callers 2

test_to_jsonMethod · 0.80

Calls 3

to_listMethod · 0.95
to_dictMethod · 0.95
universal_write_openFunction · 0.90

Tested by 2

test_to_jsonMethod · 0.64