core.bones.json

Module Contents

Classes

JsonBone

This bone saves its content as a JSON-string, but unpacks its content to a dict or list when used.

class core.bones.json.JsonBone(indexed: bool = False, multiple: bool = False, languages: bool = None, schema: Mapping = {}, *args, **kwargs)

Bases: viur.core.bones.raw.RawBone

This bone saves its content as a JSON-string, but unpacks its content to a dict or list when used. :param schema If provided we can control and verify which data to accept. Example:

>>> schema = {
>>>     "type" : "object",
>>>     "properties" : {
>>>         "price" : {"type" : "number"},
>>>         "name" : {"type" : "string"},
>>>     }
>>> }
This will only accept the provided JSON when price is a number and name is a string.
type = 'raw.json'
serialize(skel: SkeletonInstance, name: str, parentIndexed: bool) bool
unserialize(skel: viur.core.skeleton.SkeletonInstance, name: str) bool
singleValueFromClient(value: str | list | dict, *args, **kwargs)
structure() dict