wow I'd never have thought of that - Thanks!

Valid JSON




On Saturday, January 19, 2013 6:37:08 PM UTC-6, Jonathan Lundell wrote:
>
> On 19 Jan 2013, at 4:21 PM, Bill Thayer <bill....@live.com <javascript:>> 
> wrote:
>
> 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 '{', '['
>
>
>
> It looks like you're feeding jsonlint a string of the form "myobj={some 
> json object}" instead of "{some json object}". It's looking for a JSON 
> object, which must begin with { or [, and it's finding 'm'.
>
> 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