Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Contributor
Posts: 18
Registered: ‎07-24-2013
My Device: BLackberry 10
My Carrier: Mobile Apps developer

Create a json file , write Json data into it and Load the file into JsonDataAccess

Hi All,

 

I have this method call 

QList<QByteArray> SocketBase::readAllSymb(QTcpSocket *socket) {

	QList<QByteArray> listAll;
	int bytesAvail = waitForInput(socket);

	if (bytesAvail > 0) {
		//int symbolCount = 0;
		int cnt = 0;
		bool endOfLine = false;
		bool endOfStream = false;

		/* line.append(socket->readAll());
		 line.append(',');
		 endOfLine = true;*/
		while (cnt < bytesAvail && (!endOfLine) && (!endOfStream)) {

			 QByteArray ba="";

			 ba=socket->readAll();

			 listAll.append(ba);

			 if(ba.endsWith(']')){
				 endOfStream = true;
			 }
			 ba="";
		}
	}
   
	return listAll;
}

 now my Question is How to create a Dynamic file programatically and write data in to the file and load it like ....

JsonDataAccess jda;
QVariant list = jda.load(QDir::currentPath() +
                         "/app/native/assets/employees.json");

 

  

 

Developer
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: Create a json file , write Json data into it and Load the file into JsonDataAccess

Use the write() method of QFile, passing it the ByteArray...