Question: I have a query that retrive an object type and convert it to double value. Here is how I did:

```
Double.valueOf(rs.getObject("price").toString()).doubleValue()));

```

However, if the price data in DB is NULL, I got error: NullPointerException.

How can I deal with it? If it is NULL, i want to just leave it blank. 

I guess the issue is when it get null, Java cannot convert to string or to doubleValue(), How can I prevent this happen?

Answer: 
Short Answer - No. You'll have to pass the components of the decoded JSON object into a new Rectangle.

```
var jRect:Object = JSON.decode(json_string);
var rect:Rectangle = new Rectangle(jRect.x, jRect.y, jRect.width, jRect.height);

```

In this case you are lucky because the Points you mentioned are inferred from the constructor values. For more complex classes I usually make a class level fromJSON method.
Here is a copy function that I came up with. Tested it with a simple type like Rectangle. 
There is a try/catch statement there because I was getting exceptions when I would try to write to read-only properties. There should be an if statement to check if property is writable but I don't have the time or patience right now. I will come back to improve it later but for now here it is: 

```
public static function copy(source:Object, dest:Object):void
{
    for (var prop in source)
    {
        if (getQualifiedClassName(source[prop]) == "Object")
        {
            copy(source[prop], dest[prop]);
        }
        else
        {
            try // bad. should really be an if statement to check if property is writable. 
            {
                dest[prop] = source[prop];
            }
            catch (err:Error)   {}
        }
    }       
}

```