jsonpickle#
- jsonpickle(obj, filename=None, tostring=False, **kwargs)[source]#
Save any Python object to a JSON using jsonpickle.
Wrapper for the jsonpickle library: https://jsonpickle.github.io/
Note: unlike regular pickle, this is not guaranteed to exactly restore the original object. For example, at the time of writing it does not support pandas dataframes with mixed-dtype columns. If this sort of thing does not sound like it would be an issue for you, please proceed!
- Parameters:
- Returns:
Either a Python object for the JSON, a string, or save to file
Examples:
# Create data df1 = sc.dataframe(a=[1,2,3], b=['a','b','c']) # Convert to JSON and read back json = sc.jsonpickle(df1) df2 = sc.jsonunpickle(json) # Save to JSON and load back sc.jsonpickle(df1, 'my-data.json') df3 = sc.jsonunpickle('my-data.json')
New in version 3.1.0: “filename” argument