:py:mod:`core.bones.json` ========================= .. py:module:: core.bones.json Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: core.bones.json.JsonBone .. py:class:: JsonBone(*, indexed = False, multiple = False, languages = None, schema = {}, **kwargs) Bases: :py:obj:`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. .. code-block:: python # 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. Initializes a new Bone. .. py:attribute:: type :value: 'raw.json' .. py:method:: singleValueSerialize(value, skel, name, parentIndexed) Serializes a single value of the bone for storage in the database. Derived bone classes should overwrite this method to implement their own logic for serializing single values. The serialized value should be suitable for storage in the database. .. py:method:: singleValueUnserialize(val) Unserializes a single value of the bone from the stored database value. Derived bone classes should overwrite this method to implement their own logic for unserializing single values. The unserialized value should be suitable for use in the application logic. .. py:method:: singleValueFromClient(value, skel, bone_name, client_data) Load a single value from a client :param value: The single value which should be loaded. :param skel: The SkeletonInstance where the value should be loaded into. :param bone_name: The bone name of this bone in the SkeletonInstance. :param client_data: The data taken from the client, a dictionary with usually bone names as key :return: A tuple. If the value is valid, the first element is the parsed value and the second is None. If the value is invalid or not parseable, the first element is a empty value and the second a list of *ReadFromClientError*. .. py:method:: structure() Describes the bone and its settings as an JSON-serializable dict. This function has to be implemented for subsequent, specialized bone types.