AS3。如何将php中的json数组保存到sqlite中?
我有JSON数组数据来自Mysql和Php, 我想将这个JSON数组存储在SQLite中,然后像JSON数组一样将其取回 这是来自php的json数组的输出 这是从php获取数据结果的AS3代码 我已经将PHP的结果从JSON更改为字符串数组 splitByComma(extrnalString:String),我已经在SQLite中保存了它,这对我来说很好 这里是与我一起工作的代码AS3。如何将php中的json数组保存到sqlite中?,php,json,actionscript-3,Php,Json,Actionscript 3,我有JSON数组数据来自Mysql和Php, 我想将这个JSON数组存储在SQLite中,然后像JSON数组一样将其取回 这是来自php的json数组的输出 这是从php获取数据结果的AS3代码 我已经将PHP的结果从JSON更改为字符串数组 splitByComma(extrnalString:String),我已经在SQLite中保存了它,这对我来说很好 这里是与我一起工作的代码 public function processTasks():void { va
public function processTasks():void
{
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest();
varSend.url = "http://localhost/a/tasks.php?empid="+empid;
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
variables.myrequest = "get_data_array";
varLoader.load(varSend);
function completeHandler(event:Event):void
{
var returnStr:String = event.target.data.returnString;
splitByComma(returnStr);
}
}
public function splitByComma(extrnalString:String):void
{
var myArray:Array = extrnalString.split("(||)");
for(var element:String in myArray){
i++;
var innerArray:Array = myArray[element].split("|");
movie_id = innerArray[0];
movie_taskid = innerArray[1];
movie_tasktitles = innerArray[2];
movie_taskstime = innerArray[3];
movie_taskseentime = innerArray[4];
movie_tasksubject = innerArray[5];
movie_taskftime = innerArray[6];
movie_taskuid = innerArray[7];
movie_tasktsp = innerArray[8];
openDB_to_Insert();
}
JSON格式是一个字符串(可以将其解析为泛型对象,而泛型对象又可以进行字符串化,请查看更多详细信息)。然而,归根结底,它只是一个字符串,因此您需要在您的SQLite中写入(并在稍后检索)一些文本数据。请举个例子吗?请举个例子,具体是什么?在
公共函数receive(event:event):void{}
@IbrahimAyyad(1)中“我想要获取Json数组数据”
您是否尝试过类似于myString=event.data
因为JSON数据是第一条注释中提到的字符串?(2) “存储到SQLite”
什么工作(代码)不起作用?如果您向我们展示(3)“以JSON的形式再次返回”
再次展示您在阅读手册和教程时尝试过的不起作用的代码,或许我们可以帮助解决这个问题。。。我们只能帮助您修复代码。
public function processTasks():void
{
var request:URLRequest = new URLRequest();
request.url = "http://xxxxxxxxxxxxxxxxxx.xxx/a/tasks.php?
empid="+empid;
request.requestHeaders = [new URLRequestHeader("Content-Type",
"application/json")];
request.method = URLRequestMethod.GET;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, receive);
loader.load(request);
}
public function receive(event:Event):void
{
// here i want get the Json Array data then store in to SQLite
// And get back again as a JSON .
}
public function processTasks():void
{
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest();
varSend.url = "http://localhost/a/tasks.php?empid="+empid;
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
variables.myrequest = "get_data_array";
varLoader.load(varSend);
function completeHandler(event:Event):void
{
var returnStr:String = event.target.data.returnString;
splitByComma(returnStr);
}
}
public function splitByComma(extrnalString:String):void
{
var myArray:Array = extrnalString.split("(||)");
for(var element:String in myArray){
i++;
var innerArray:Array = myArray[element].split("|");
movie_id = innerArray[0];
movie_taskid = innerArray[1];
movie_tasktitles = innerArray[2];
movie_taskstime = innerArray[3];
movie_taskseentime = innerArray[4];
movie_tasksubject = innerArray[5];
movie_taskftime = innerArray[6];
movie_taskuid = innerArray[7];
movie_tasktsp = innerArray[8];
openDB_to_Insert();
}