JsonCpp – pyne.jsoncpp

All functionality may be found in the jsoncpp package:

from pyne import jsoncpp

For examples of usage, please refer to the User’s Guide entry for JsonCpp: Python bindings for JsonCpp.

Python wrapper for jsoncpp.

class pyne.jsoncpp.FastWriter

A class to convert values in memory to minified strings.

enable_yaml_compatibility()

Enables YAML compatability for output.

write()

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

Parameters
valueValue or anything Value-convertable
Returns
sstr
class pyne.jsoncpp.Reader

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

parse()

Read a Value from a JSON document.

Parameters
documentstring or file-like object

Any JSON formatted string

collect_commentsbool, optional

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

Returns
rootValue

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

class pyne.jsoncpp.StyledWriter

A class to convert values in memory to expanded strings.

write()

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

Parameters
valueValue or anything Value-convertable
Returns
sstr
class pyne.jsoncpp.Value(document=None, view=False)

An in-memory JSON value.

Parameters
documentobject, optional

Python value to convert to a JSONic form.

viewbool, optional

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

append()

Adds the value to the end of the array.

clear()

Removes all elements of JSON value.

count()

Counts the number of instances of value.

extend()

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

get()

Returns key if present, or default otherwise.

index()

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

insert()

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.

remove()

Removes the first instance of value from the array.

reverse()

Reverses the array in place.

type()

The type number of this JSON value.

type_name()

The type name of this JSON value.

values()

Returns a list of values in JSON object.