JSON's foreground and background operations implement code _json

Source: Internet
Author: User
Examples are as follows:
Copy Code code as follows:

Name: <span id= "fname" ></span><br/>
Last Name: <span id= "lname" ></span><br/>
<script type= "Text/javascript" >
var txt = ' {employees ': [' +
' {"FirstName": "Bill", "LastName": "Gates"}, ' +
' {"FirstName": "George", "LastName": "Bush"}, ' +
' {"FirstName": "Thomas", "LastName": "Carter"}]} ';
var obj = eval ("+ txt +"));
document.getElementById ("FName"). Innerhtml=obj.employees[1].firstname
document.getElementById ("LName"). Innerhtml=obj.employees[1].lastname

The app then stores the data into JSON in the foreground page and sends it back to the background.
Attached to the application of a picture:

The Modifycellstyle is responsible for the style part of the font, but it cannot control the right and top alignment of the center and the center alignment. Modifystring is to modify the contents of the cell.
Use the following format:
Copy Code code as follows:

var arrobj = []; Action
Var act =
{"Action": "Modifycellstyle", "bold": "True", "Italic": "false", "CellIndex": rowx+ ":" +rowy};
Arrobj.push (ACT); });
var sobj = json.stringify (arrobj);

Converts JSON to an array.
Take the Modifycellstyle method as an example: bold (Bold), Itelic (Italic), underline (underlined) value is a Boolean value. Take True or false. The values of other sizestring,textcolorstring,cellcolorstring such as String,cellindex are "x,y" i.e. horizontal and vertical coordinates.
This API is used primarily in Excel for the operation of cells. Record its history operation. When you click Save, the JSON-converted string is passed to the background, receiving the data backstage, and manipulating Excel from the background.
Of course this is to load the Json2.js file. You can download it yourself

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.