bool GameMapEncounterAreaParser::Parse(std::string json, GameMapEncounterArea *encounterArea) {
    JSONNode assetListNode = libjson::parse(json);

    JSONNode::const_iterator i = assetListNode.begin();

    while (i != assetListNode.end()) {
        if (i->name() == "mobs" && i->type() == JSON_ARRAY) {
            this->logger->debug() << "parsing mobs";
            JSONNode::const_iterator j = i->begin();

            while (j != i->end()) {
                if (j->type() == JSON_NODE) {
                    JSONNode::const_iterator k = j->begin();

                    while (k != j->end()) {
                        if (k->name() == "enemies") {
                            this->logger->debug() << "parsing enemies for mob";
                            JSONNode::const_iterator l = k->begin();

                            std::string r = "";
                            std::vector<std::string> mob;

                            while (l != k->end()) {
                                this->logger->debug() << std::setfill ('0') << std::setw(sizeof(unsigned char)*2)
                                << std::hex << l->type();

                                if (l->type() == JSON_STRING) {
                                    r += l->as_string() + ", ";
                                    mob.push_back(l->as_string());
                                }

                                l++;
                            }


                            this->logger->debug() << "parsed mob [" << r << "]";

                            encounterArea->mobs.push_back(mob);
                        }

                        k++;
                    }
                }

                j++;
            }
        }

        i++;
    }

    return true;
}
Handle<Object> AtJsonParser::parse( const JSONNode &n ) {
    Isolate* isolate = Isolate::GetCurrent();
    Handle<Object> ret = Object::New( isolate );

    JSONNode::const_iterator i = n.begin();
    while ( i != n.end() ) {
        std::string node_name = i->name();
        if ( node_name == "serverTime" ||
             node_name == "response" ||
             node_name == "data" ||
             node_name == "tick" ||
             node_name == "ATBarHistory" ||
             node_name == "ATSymbol" ||
             node_name == "ATLoginResponse" ||
             node_name == "time" ||
             node_name == "open" ||
             node_name == "high" ||
             node_name == "low" ||
             node_name == "close" ||
             node_name == "ATTickHistory" ||
             node_name == "offsetDatabaseDate" ||
             node_name == "tradeLastPrice" ||
             node_name == "quoteBidPrice" ||
             node_name == "quoteAskPrice" ||
             node_name == "ATMarketMoversDb" ||
             node_name == "recordSymbol" ||
             node_name == "itemSymbol" ||
             node_name == "itemLastPrice" ||
             node_name == "ATQuoteDb" ||
             node_name == "priceData" ||
             node_name == "dateTime" ||
             node_name == "ATQuoteStream" ||
             node_name == "lastPrice" ||
             node_name == "bidPrice" ||
             node_name == "askPrice" ||
             node_name == "prevClose" ||
             node_name == "afterMarketClose" ||
             node_name == "lastUpdateTime" ||
             node_name == "marketMovers" ||
             node_name == "closePrice" ||
             node_name == "lastDateTime" ||
             node_name == "beginDateTime" ||
             node_name == "endDateTime"
            ) {
            ret->Set( String::NewFromUtf8( isolate, node_name.c_str() ),
                      parse( *i ) );
        }
        else if ( filterAsString( node_name ) ) {
            ret->Set( String::NewFromUtf8( isolate, node_name.c_str() ),
                      String::NewFromUtf8( isolate, i->as_string().c_str() ) );
        }
        else if ( filterAsNumber( node_name ) ) {
            ret->Set( String::NewFromUtf8( isolate, node_name.c_str() ),
                      Number::New( isolate, i->as_float() ) );
        }
        else if ( filterAsInteger( node_name ) ) {
            ret->Set( String::NewFromUtf8( isolate, node_name.c_str() ),
                      Integer::New( isolate, i->as_int() ) );
        }
        else if ( filterAsBoolean( node_name ) ) {
            ret->Set( String::NewFromUtf8( isolate, node_name.c_str() ),
                      Boolean::New( isolate, i->as_bool() ) );
        }
        else if ( i->type() == JSON_ARRAY ) {
            JSONNode::const_iterator j = i->begin();
            std::vector< Handle<Object> > vec;
            while ( j != i->end() ) {
                vec.push_back( parse( *j ) );
                ++j;
            }
            Handle<Array> arr = Array::New( isolate, vec.size() );
            for ( size_t idx = 0; idx < vec.size(); idx++ ) {
                arr->Set( idx, vec[idx] );
            }
            ret->Set( String::NewFromUtf8( isolate, node_name.c_str() ), arr );
        }
        ++i;
    }
    return ret;

}