public static function unserialize($serialized_quantity) {
        if (is_array($serialized_quantity)) {
            $json_array = $serialized_quantity;
        } else if (is_object($serialized_quantity)) {
            $json_array = json_decode(json_encode($serialized_quantity), true);
        } else {
            $json_array = json_decode($serialized_quantity, true);
        }
        if (!is_array($json_array)) {
            throw new Exception("Invalid serialized quantity", 1);
        }

        return static::fromSatoshis($json_array['value'], $json_array['precision']);
    }