JSON C++ (cyclus.jsoncpp)

Python wrapper for jsoncpp.

class cyclus.jsoncpp.CustomWriter

A class to convert values in memory to expanded strings with a custom formtting.

write(value)

Writes a value out to a custom human-readable JSON string.

Parameters:

value : Value or anything Value-convertable

Returns:

s : str

class cyclus.jsoncpp.FastWriter

A class to convert values in memory to minified strings.

enable_yaml_compatibility()

Enables YAML compatability for output.

write(value)

Writes a value out to a compact, not human-readable JSON string.

Parameters:

value : Value or anything Value-convertable

Returns:

s : str

class cyclus.jsoncpp.Reader

A class to convert strings and files to values in memory.

parse(document, collect_comments=True)

Read a Value from a JSON document.

Parameters:

document : string or file-like object

Any JSON formatted string

collect_comments : bool, optional

True to collect comment and allow writing them back during serialization, and False to discard comments.

Returns:

root : Value

The root value of the document if it was successfully parsed.

class cyclus.jsoncpp.StyledWriter

A class to convert values in memory to expanded strings.

write(value)

Writes a value out to a human-readable JSON string.

Parameters:

value : Value or anything Value-convertable

Returns:

s : str

class cyclus.jsoncpp.Value(document=None, view=False)

An in-memory JSON value.

Parameters:

document : object, optional

Python value to convert to a JSONic form.

view : bool, optional

Flag for whether this is a view or a copy of its underlying value.

append(value)

Adds the value to the end of the array.

clear()

Removes all elements of JSON value.

count(value)

Counts the number of instances of value.

extend(itr)

Exetend the array by adding elements from the iterable to the end.

get(key, default=None)

Returns key if present, or default otherwise.

index(value, start=None, stop=None)

Finds the first index of value on range from start to stop.

insert(ind, value)

Inserts the value at position ind.

isarray()

True if JSON array or null, False otherwise.

isbool()

True if JSON boolean, False otherwise.

isfloat()

True if is any JSON float or double type, False otherwise.

isint()

True if is any JSON integer type, False otherwise.

isnull()

True if JSON null, False otherwise.

isobject()

True if JSON object or null, False otherwise.

isstring()

True if JSON string, False otherwise.

items()

Returns a list of items in JSON object.

keys()

Returns a list of keys in JSON object.

pop(i)
popitem(k)
remove(value)

Removes the first instance of value from the array.

reverse()

Reverses the array in place.

setdefault(k, d=None)
type()

The type number of this JSON value.

type_name()

The type name of this JSON value.

update(d)
values()

Returns a list of values in JSON object.