DeserializationError when trying to load a document generated with bokeh 1.0.2

Hello,

I had stored several bokeh documents as json files in a database using bokeh 1.0.2 and as I tried to reload them now (with bokeh 2.2.1), I face the following error:

DeserializationError: Percent expected Real, got {'value': 0.5} of type dict

Basically what I do is

doc = Document.from_json(data)

And while data is a pretty big document, the part of it generating the error is the following:

{
    "attributes": {
        "bottom_units": "screen",
        "fill_alpha": {
            "value": 0.5
        },
        "fill_color": {
            "value": "lightgrey"
        },
        "left_units": "screen",
        "level": "overlay",
        "line_alpha": {
            "value": 1.0
        },
        "line_color": {
            "value": "black"
        },
        "line_dash": [
            4,
            4
        ],
        "line_width": {
            "value": 2
        },
        "plot": null,
        "render_mode": "css",
        "right_units": "screen",
        "top_units": "screen"
    },
    "id": "1072",
    "type": "BoxAnnotation"
}

Is there some sort of correction I could apply to the json to make it compatible with the newer version?

Thanks!
Cyril

Try replacing

"fill_alpha": {
    "value": 0.5
},

with

"fill_alpha": 0.5,

Thanks! This is indeed the solution.

I wrote a quick and dirty script to go through the whole document

def preprocess(d):
    for k, v in d.items():
        if isinstance(v, dict):
            if len(v.keys()) == 1 and "value" in v:
                if k != "label":
                    d[k] = v["value"]
            else:
                preprocess(v)
        elif isinstance(v, list):
            for vv in v:
                if isinstance(vv, dict):
                    preprocess(vv)

and it works.