allensdk.core.json_utilities module

class allensdk.core.json_utilities.JsonComments[source]

Bases: object

classmethod read_file(file_name)[source]
classmethod read_string(json_string)[source]
classmethod remove_comments(json_string)[source]

Strip single and multiline javascript-style comments.

Parameters:
json : string

Json string with javascript-style comments.

Returns:
string

Copy of the input with comments removed.

Note: A JSON decoder MAY accept and ignore comments.
classmethod remove_multiline_comments(json_string)[source]

Rebuild input without substrings matching //.

Parameters:
json_string : string

may or may not contain multiline comments.

Returns:
string

Copy of the input without the comments.

allensdk.core.json_utilities.json_handler(obj)[source]

Used by write_json convert a few non-standard types to things that the json package can handle.

allensdk.core.json_utilities.read(file_name)[source]

Shortcut reading JSON from a file.

allensdk.core.json_utilities.read_url(url, method='POST')[source]
allensdk.core.json_utilities.read_url_get(url)[source]

Transform a JSON contained in a file into an equivalent nested python dict.

Parameters:
url : string

where to get the json.

Returns:
dict

Python version of the input

Note: if the input is a bare array or literal, for example,
the output will be of the corresponding type.
allensdk.core.json_utilities.read_url_post(url)[source]

Transform a JSON contained in a file into an equivalent nested python dict.

Parameters:
url : string

where to get the json.

Returns:
dict

Python version of the input

Note: if the input is a bare array or literal, for example,
the output will be of the corresponding type.
allensdk.core.json_utilities.write(file_name, obj)[source]

Shortcut for writing JSON to a file. This also takes care of serializing numpy and data types.

allensdk.core.json_utilities.write_string(obj)[source]

Shortcut for writing JSON to a string. This also takes care of serializing numpy and data types.