json

The json module helps with from python objects to json encoded strings and back

dumps(obj)

Dumps the given python object into a json encoded string

(note: this function is also available under the alias ‘encode’)

Parameters:

obj (object) – the python object to encode

Return type:

str

Returns:

an encoded string with the contents of the python object

loads(s)

Loads the given JSON encoded string into a python object

The function will throw an error if the string is not valid json

(note: this function is also available under the alias ‘decode’)

Parameters:

s (str) – the string to decode

Return type:

object

Returns:

the decoded string s as a python object