Releases: fenhl/lazyjson
lazyjson 3.0.2
lazyjson 3.0.1 — better defaults for SFTPFile
This release adds more useful defaults for the pkey
and hostkey
parameters on SFTPFile
, reading them from ~/.ssh/id_rsa
and ~/.ssh/known_hosts
, respectively. This is a breaking change, hence the major version bump. The new abstract methods on BaseFile
introduced in 2.8.0 could also be considered a breaking change.
The 3.0.1 patch fixes a syntax error introduced by a typo in 3.0.0.
lazyjson 2.8.0 — CachedFile
This release adds the CachedFile
class.
The CachedFile
constructor takes a mutable mapping cache
and another BaseFile
. Any access of the CachedFile
's value will be retrieved from the cache if present, otherwise the inner BaseFile
's value is stored in the cache and returned.
This class performs no cache invalidation whatsoever except when the CachedFile
's value is modified.
lazyjson 2.7.0 — retry loads
With this update, loading a File
from disk will be retried up to 10 times if the load fails with a JSONDecodeError
. This avoids intermittent errors when the file is in the process of being written to disk. The optional tries
argument of the File
constructor can be used to override the number of attempts; use 1
to turn this feature off.
lazyjson 2.6.2
This release improves handling of JSON numbers by decoding them into decimal.Decimal
objects rather than float
s. This avoids losing precision on read.
lazyjson 2.6.1
This release changes the structure of the project from a Python module to a Python package to improve Windows compatibility.
lazyjson 2.6.0 — initialize files
This release adds the optional init
argument to the File
constructor. If set to a JSON-encodable value, the file at the given path is created if it doesn't exist, using the value as the initial contents. If the file already exists, the contents are unchanged. This is done as part of the File
constructor (i.e. not lazily).
lazyjson 2.5.0 — Node.parent
This release adds the Node.parent
property, which returns a node's parent node.
lazyjson 2.4.0 — Node.set
This release adds the set
method, which can be used to replace the contents of a node, to all nodes instead of just the root node. Example:
>>> f = lazyjson.File('example-file.json')
>>> node = f['someKey']
>>> print(f)
{'someKey': ['a', 'b', 'c', 'd', 'e', 'f']}
>>> node.set(42)
>>> print(f)
{'someKey': 42}
lazyjson 2.3.0 — HTTPFile
This release adds the HTTPFile
class, which uses requests to represent a JSON file accessed via HTTP. It can be used for REST APIs, or JSON files which happen to be on the web and change often.
It also adds two read-only properties for Node
objects to the API:
key_path
, which returns a list of keys (strings, integers, and slices) which can be followed from the root node to this node,- and
key
, which returns the last element of the key path (orNone
if the key path is empty because you're looking at the root node).