About JSON big Text Processing

Source: Internet
Author: User
JSON has serious efficiency problems when processing big text data. During deserialization, the CPU usage may even reach 80%,
The solution is to split a small segment on the client and assemble it on the server, as shown below: 1 // large text Optimization
2 var origincontent = article. content;
3 var contentlen = origincontent. length;
4 If (contentlen> 1000 ){
5 Article. content = ''; // clear it !!!
6 var Len = math. Ceil (contentlen/ 1000 );
7 var splitcontent = [];
8 For (VAR I = 0; I <Len; I ++ ){
9 var start = I * 1000;
10 var end = start + 1000;
11 if (end> contentLen-1) End = contentlen-1;
12 splitcontent. Push (origincontent. substring (START, end ));
13}
14 Article. contentsegments = splitcontent;
15}

Then assemble them on the server: 1if (article. content. Length = 0)
2 {
3 if (article. contentsegments! = NULL & article. contentsegments. Count> 0)
4 {
5 stringbuilder Buf = new stringbuilder ();
6 foreach (string s in article. contentsegments)
7 {
8 Buf. append (s );
9}
10 Article. content = Buf. tostring ();
11}
12}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.