代码创建如下:
function create_story_json_file()
{
//Update the last edited page:
img_dataURLs[current_page]= drawing_plate.toDataURL("image/png");
create_display_img_url(current_page);
var page_num= total_page_num; //Story total page number
var page_cont= new Array();
var page_view= new Array();
//Page View:( as the pages is clicked, the page views have to be shown.
page_view= display_img_dataURL;
var img_data_URL; //if it's a variable only, you have to assign the first value in the declaration, or the tag would disappear.
var stamp_arr= new Array();
var rec_arr= new Array();
var background_msc;
//For each Story:
alert("total_page_num :"+ total_page_num );
for(var p_number=0 ; p_number < total_page_num ; p_number++)
{
img_data_URL= img_dataURLs[p_number];
//Stamp
stamp_arr= []; //reset.
var stamp_arr_for_current_page= stamp_for_all_pages[ p_number ].arr;
for(var stamp_num= 0; stamp_num < stamp_arr_for_current_page.length ; stamp_num++)
{
stamp_arr.push( stamp_arr_for_current_page[stamp_num].get_stmp_json_obj );
}
alert("stamp_arr.length is:" + stamp_arr.length);
//Rec:
rec_arr= [];
var rec_objs_at_certain_page= records_pages_arr[ p_number ].rec_objs;
for(var rec_num= 0; rec_num < rec_objs_at_certain_page.length; rec_num++)
{
rec_arr.push( rec_objs_at_certain_page[ rec_num ].get_rec_json_obj ); //check if rec_objs_at_certain_page[ rec_num ] is a rec_object!
}
alert("rec_arr length is: " + rec_arr.length);
//Background_music:
var bgr_msc_in_certain_page= back_ground_music_arr[ p_number ];
alert ("bgr_msc_in_certain_page.created" + bgr_msc_in_certain_page.created);
background_msc= bgr_msc_in_certain_page.get_bgr_msc_json_obj;
var page_content_json_obj= {
img_data_url: img_data_URL,
stamp:stamp_arr,
record: rec_arr,
bgr_msc: background_msc
}
page_cont.push(page_content_json_obj);
}
var story_json_obj= {
page_number: page_num,
page_content: page_cont,
page_img_view: page_view
}
//Change to JSON String and write it to the file.
story_json_str= JSON.stringify(story_json_obj);
}
我很困惑为什么结果 JSON string: story_json_str会是:
{"page_number":1,
"page_content":[{"img_data_url":"data:image/base64......lots of character"}]}
仅此而已,“page_content”中的“stamp”、“record”和“bgr_msc”在哪里?
为什么“page_img_view”也会消失?
他们为什么会错过?
请解释并更正代码。
Ps:我在Android系统上工作,通过HTML5的特性将JSON字符串存储到一个文件中。我没有调试平台可以使用...