コード例 #1
0
ファイル: ToyControl.cpp プロジェクト: CatSalad/LinkIt-Toy
void ToyControl::init(char* json)
{
	JsonParser<32> parser;
  JsonArray root = parser.parse(json);

  if (!root.success()) {
    HTTP_DEBUG_PRINTLN("JsonParser.parse() failed");
    return;
  }
	else {
		if (root.size() == 0) {
			return;
		}
		
		id = String((char*)root[0]["id"]);
		battleId = String((char*)root[0]["battle_id"]);
		toyDeviceId = String((char*)root[0]["toy_device_id"]);
		type = String((char*)root[0]["type"]);
		
		HTTP_DEBUG_PRINT("id: ");
		HTTP_DEBUG_PRINTLN(id);
		HTTP_DEBUG_PRINT("battleId: ");
		HTTP_DEBUG_PRINTLN(battleId);
		HTTP_DEBUG_PRINT("toyDeviceId: ");
		HTTP_DEBUG_PRINTLN(toyDeviceId);
		HTTP_DEBUG_PRINT("type: ");
		HTTP_DEBUG_PRINTLN(type);
	}
}
コード例 #2
0
ファイル: json.cpp プロジェクト: arnbak/meewod-harmattan
/*!
  Parses the JSON string \a str as a QVariant.

  If the parse succeeds, this function returns true and the QVariant can
  be accessed using result(). If the parse fails, this function returns
  false and the error message can be accessed using errorMessage().
 */
bool JsonReader::parse(const QString &str)
{
    JsonLexer lexer(str);
    JsonParser parser;
    if (!parser.parse(&lexer)) {
        m_errorString = parser.errorMessage();
        m_result = QVariant();
        return false;
    }
    m_errorString.clear();
    m_result = parser.result();
    return true;
}
コード例 #3
0
Configuration::Configuration(std::string json) {
//	LOG(INFO) << "Start JSON Parser";
	this->attributes = json;
	JsonParser jp;
//	LOG(INFO) << "Start JSON Parser 2";
	std::shared_ptr<AttributeMap> property_map = jp.parse(json);
//	LOG(INFO) << "end JSON Parser";
	this->camera_attribute =  std::static_pointer_cast<CameraAttribute>( (*property_map)["camera"] );
	this->image_processor_attribute = std::static_pointer_cast<ImageProcessorAttribute>( (*property_map)["image_processors"] );

	//	std::cout<<"============== configuration =============="<<std::endl;
	//	std::cout<<"camera name:"<< this->camera_attribute->getName() <<std::endl;
	//	std::cout<<"Image Processor name:"<<this->image_processor_attribute->getName()<<std::endl;
	//	std::cout<<"Image Processor size:"<<this->image_processor_attribute->getImageProcessorAttributeVector().size()<<std::endl;
	std::vector< std::shared_ptr<ImageProcessorAttribute> > ipp =
			this->image_processor_attribute->getImageProcessorAttributeVector();
	//	for (std::vector<ImageProcessorAttribute*>::size_type i = 0; i < ipp.size(); ++i){
	//		std::cout << "processor name: " << ipp[i]->getName() << std::endl;
	//	}
}
コード例 #4
0
void WebSocketRailsChannel::dispatch(String eventName, 
	String data) {
	
	if(eventName.equals("websocket_rails.channel_token")) {
		JsonParser<16> parser;	

		char buffer[data.length() + 1];
		data.toCharArray(buffer, data.length() + 1);

		Parser::JsonObject frame = parser.parse(buffer);
		this->token = frame["token"];
	}
	else {
		if (! callbacks.contains(eventName))
			return;
		
		LinkedList<EventCompletionBlock> eventCallbacks = callbacks[eventName];
		for(int i = 0; i < eventCallbacks.size(); i++){
			EventCompletionBlock callback = eventCallbacks.get(i);
			callback(data);
		}
	}	
}
コード例 #5
0
ファイル: main.cpp プロジェクト: brandonphelps/my_cppjson
int main(int argc, char* argv[])
{
  if(argc != 2)
  {
    std::cout << "Please provide a filename" << std::endl;
  }
  else
  {
    JsonParser p;
    
    std::map<std::string, std::string> configFile = p.parse(argv[1]);

    std::cout << "file contents" << std::endl;

    std::cout << "project url: " << configFile["project url"] << std::endl;

    for(std::map<std::string, std::string>::iterator it = configFile.begin(); it != configFile.end(); ++it)
    {
      std::cout << it->first << " : " << it->second << std::endl;
    }
  }
  return 0;
}