# ParticleJSONDecoder¶

class plasmapy.particles.ParticleJSONDecoder(*, object_hook=None, **kwargs)

Bases: json.decoder.JSONDecoder

A custom JSONDecoder class to deserialize JSON objects into PlasmaPy particle objects.

Parameters: object_hook – If specified, will be called with the result of every JSON object decoded and its return value will be used in place of the given dict. This can be used to provide custom deserializations (e.g. to support JSON-RPC class hinting) (If not specified, then defaults to particle_hook.). **kwargs – Any keyword accepted by JSONDecoder.

Methods Summary

 decode(s[, _w]) Return the Python representation of s (a str instance containing a JSON document). particle_hook(json_dict) An object_hook utilized by the json deserialization processes to decode json strings into a plasmapy particle class (AbstractParticle, CustomParticle, DimensionlessParticle, Particle). raw_decode(s[, idx]) Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended.

Methods Documentation

decode(s, _w=<built-in method match of re.Pattern object>)

Return the Python representation of s (a str instance containing a JSON document).

static particle_hook(json_dict)

An object_hook utilized by the json deserialization processes to decode json strings into a plasmapy particle class (AbstractParticle, CustomParticle, DimensionlessParticle, Particle).

raw_decode(s, idx=0)

Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended.

This can be used to decode a JSON document from a string that may have extraneous data at the end.