var students = new Array() ; students[0] = "onepiece"; students[1] = "naruto"; students[2] = "bleach"; var json = JSON.stringify(students,switchUpper); function switchUpper(key, value) { return value.toString().toUpperCase(); } alert(json);
He can receive arrays, and can have functions to handle
In addition, there is a third parameter, which is convenient for viewing data during development.
JSON.stringify({a:1,b:2,c:3,d:{aa:11,bb:22,cc:33}},null,4);
The third parameter is the number of indented spaces
The third parameter can also be used with '\t' My Google Chrome defaults to 4 spaces