My app stores EDA information (cad programs for designing microchips) so 
storing cell attributes in a json object and taking advantage of json rpc 
would be beneficial. I am trying out Alex's new 'json' data type and with 
the serializer and IS_JSON() validator. Using the controller function below 
I've manage to create a json object of cell parameters (aka, attributes). 
In the function's comments is the output from the function but this output 
fails validation in http://jsonlint.com/ saying that 
RESULTS:

Parse error on line 1:
myobj={    "L": [ 
^
Expecting '{', '['


CONTROLLER FUNCTION: (the myobj value is copied from my cell's edit page 
after being inserted into my Oracle DB.
def json_parameters(param_names):
    """takes an array of parameter names which are attributes to a design 
cell
    then looks up the default value and unit in the attributes table 
    and returns an array of json dictionary objects to be inserted in the 
cell's
    parameters field as a json object
    if param_names = ["L", "len", "R", "INST", "model", "REF"]
    myobj={
    "L": [
        "0.001",
        "nH"
    ],
    "len": [
        "1",
        "??m"
    ],
    "R": [
        "0.5",
        "Ohm"
    ],
    "INST": [
        "i",
        "TEXT"
    ],
    "model": [
        "m",
        "TEXT"
    ],
    "REF": [
        "r",
        "TEXT"
    ]
}
    """
    
    params={}
    for a in param_names:
     #   dbg.set_trace()
        rows = 
db(db.attribute.name.lower()==a.lower()).select(db.attribute.name,
                                                              
db.attribute.default_value,
                                                              
db.attribute.unit)
        row = rows[0]
        param = ('{}'.format(row.default_value),
                 '{}'.format(row.unit))
        params.update({'{}'.format(row.name):param})
       
    return json(params)

Any idea which is correct or how to fix it?

Thank you,
Bill

-- 



Reply via email to