0

i have JSON Array data come from Mysql and Php , i want to store this JSON Array in SQLite and Get it back Like A JSON Array

this the output of the json array it come from the php

{
"task": [
    {
        "id": "1",
        "tid": "100",
        "ttitles": "test",
        "stime": "2018-10-08 02:40:28",
        "seentime": null,
        "subject": "Testing",
        "ftime": null,
        "uid": "1101",
        "tsp": "11001"
    },
    {
        "id": "2",
        "tid": "101",
        "ttitles": "tesst",
        "stime": "2018-10-08 02:41:17",
        "seentime": null,
        "subject": "Tessting",
        "ftime": null,
        "uid": "1101",
        "tsp": "110001"
    }
]
}

and this the AS3 code to get the data result from php

        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 .
    }
6
  • JSON format is a String (which can be parsed into generic Object, which is, in turn, can be stringified back, look help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/… for more details). Yet, ultimately, it is just a String so you are to write (and retrieve at a later moment) some text data into that SQLite of yours. Commented Oct 14, 2018 at 0:58
  • any example please ? Commented Oct 14, 2018 at 1:42
  • Any example please of what, exactly? Commented Oct 14, 2018 at 5:44
  • in the public function receive(event:Event):void{ } Commented Oct 14, 2018 at 14:40
  • 2
    @IbrahimAyyad (1) "i want get the Json Array data" did you try something like myString = event.data; since JSON data is a String as told in first comment? (2) "store in to SQLite" what effort (code) from your research is not working? Maybe we can help fix that if you show us (3) "get back again as a JSON" again show code of what you've tried from reading manuals & tutorials that is not working... We can only help you fix your code. Commented Oct 14, 2018 at 19:20

1 Answer 1

1

i do already change the result come from the PHP from JSON to String_Array with splitByComma(extrnalString:String) , i save it in SQLite Already and this good for me .

Here the Code that work With me ;

    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();
            }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.