Creating and parsing huge strings using javascript?

I have a simple piece of data that I store on the server as a simple string. This is ridiculous, but it looks like this:

name|date|grade|description|name|date|grade|description|repeat for a long time

this string can be up to 1.4 MB in size. The idea is that this is a bunch of student records simply strung on a simple pipe breakdown. This is a very bad serialization method.

As soon as this massive line is pressed to the client, it is again channelized into student records using javascript.

I determine how long it takes to create and split these lines on the client side. The time is actually quite good, the slowest run I've seen on several different machines is 0.2 seconds for 10,000 student records, which has a final row size of ~ 1.4 MB.

I understand that this is rather strange, just wondering if there are any problems with creating and breaking such large lines using javascript? I don’t know how different browsers implement their javascript engines. I tried this in the “main” browsers, but I don’t know how it will be done in earlier versions of each of them.

Yes, looking for any comments on this, this is more for fun than anything else!

thank

+5
source share
3 answers

1.4mb , - . 800 ( ), .

, , , , . , , ajax ?

+1

, 'string'.slice(from, to) , list.push() - .

- , , , IE. string.charAt(x) , . , , , .

JSON, , IE8/Webkit/FF3.5, JSON-, JSON.parse(data). eval(JSON) , , , , . .

- AJAX , .

+1

, S. Mark x-fer AJAX, () JavaScript (, , ) - JS (, , ).

Browser-based JS seems like a weekly link in the-x-fer data chain, and I don't want to run unmonitored, as browsers are updated from time to time, and hacking JS-x-fer can be an unforeseen side effect!

+1
source

All Articles