Android Question BLOB filed JSON error

elitevenkat

Active Member
Licensed User
Longtime User
hi
When i try to move records from MySql to B4A using php script, i get "RuntimeException JSON Array expected." error message.

When i run the php script from browser the output seems to be in correct JSON format.

When i make the BLOB field data as NULL, the B4A app runs without error.

I have attached screen shot of MySql table data, JSON output returned when executed from browser and the relevant part of PHP code.
The image in BLOB field is being displayed correctly in the PHP web application (ej1.png)

Need help. I had spent lot of time on my own without success.
 

Attachments

  • ej.png
    ej.png
    75.6 KB · Views: 156
  • ej1.png
    ej1.png
    41.9 KB · Views: 161
  • ej2.png
    ej2.png
    98.2 KB · Views: 183

elitevenkat

Active Member
Licensed User
Longtime User
Hi Erel. Json output attached as txt file. From beginning i was using PHP. I have seen RDC. No particular reason for not using RDC. All my back end applications are in PHP so far. Will try to switch to RDC in future projects.
 

Attachments

  • JSON.txt
    3 KB · Views: 148
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tried it with this code and it works:
B4X:
Dim parser As JSONParser
parser.Initialize($"[{"pckey":"54","fbqpckey":"9","srno":"0000000001","fbqtypepckey":"3","fbchoice":"NA","eimg":"iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAP3SURBVDhPrZTdbxRlFMZ\/M7PT6W67H6VSaAWMtkVTglZtbII1KFQNIb0iJd4YQ\/yIFybe6IX+Bd7KjdxoMBoTIGma1IApNYJJRdI0RApYAtJKy3Zbtx\/bhc7sfHpmtlusSK98d2ff2fe855nnPOd5Rwlk8D8PZSNQZ34W5\/I3+NlhglIOJfEoalMXVe1HiKXSD6Xyn6DOwl\/Ypw6gOKNU7epFbegAI0lgLeLPjeKM9eEl9xI\/fJpYbeIB8AdAV0ZPEZw7jNH9CVrLEfBM8F1Q5BsKpegEMR3v+jGss58T6xmium3\/OuB1oOZv3+MP95DoOQ7xHSjeXdYpLsDRCBf1FEHxOmb\/+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","fbchoice":"Exllent","eimg":""},{"pckey":"65","fbqpckey":"10","srno":"0000000002","fbqtypepckey":"1","fbchoice":"Good","eimg":""},{"pckey":"66","fbqpckey":"10","srno":"0000000003","fbqtypepckey":"1","fbchoice":"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd \u0bae\u0bca\u0bb4\u0bbf","eimg":""},{"pckey":"67","fbqpckey":"10","srno":"0000000004","fbqtypepckey":"1","fbchoice":"Can be improved","eimg":""},{"pckey":"68","fbqpckey":"10","srno":"0000000005","fbqtypepckey":"1","fbchoice":"Poor","eimg":""},{"pckey":"69","fbqpckey":"10","srno":"0000000006","fbqtypepckey":"1","fbchoice":"Bad","eimg":""},{"pckey":"74","fbqpckey":"11","srno":"0000000001","fbqtypepckey":"4","fbchoice":"Excellect","eimg":""},{"pckey":"75","fbqpckey":"11","srno":"0000000002","fbqtypepckey":"4","fbchoice":"Good","eimg":""},{"pckey":"76","fbqpckey":"11","srno":"0000000003","fbqtypepckey":"4","fbchoice":"Good","eimg":""},{"pckey":"84","fbqpckey":"12","srno":"0000000001","fbqtypepckey":"2","fbchoice":"Yes","eimg":""},{"pckey":"85","fbqpckey":"12","srno":"0000000002","fbqtypepckey":"2","fbchoice":"No","eimg":""},{"pckey":"86","fbqpckey":"11","srno":"0000000000","fbqtypepckey":"4","fbchoice":"Poor","eimg":""},{"pckey":"87","fbqpckey":"11","srno":"0000000000","fbqtypepckey":"4","fbchoice":"Poor","eimg":""},{"pckey":"88","fbqpckey":"11","srno":"0000000000","fbqtypepckey":"4","fbchoice":"Poor","eimg":""}]"$)
Log(parser.NextArray)
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
I've tried it with this code and it works:
B4X:
Dim parser As JSONParser
parser.Initialize($"[{"pckey":"54","fbqpckey":"9","srno":"0000000001","fbqtypepckey":"3","fbchoice":"NA","eimg":"iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAYAAACpF6WWAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8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i4mJHNAv9IvpFc3heZfYdUcfV8MdvkX3iJNs6Dv6jUXLb8PJb5GaehLuiUUyjodHAkLKiEt3weAgjVZWYKu2R0yTHR62StcI8dwpdbF0FXNO0chTySy7ety1sed4n2JwSxpIsrNTV46rI7IfdlqYHwlSdWyJ7qZbEu+Nkqisoq8e08veRTAz1zQkmxtoIrkyiFExUKTFsRLjVFzDVluplncsT3BzvpPrt9YAPMK2Ah42bvPAjsauf0RC7RDxto+oqnmhrFgzm3BcI2j\/l8Y49UWP+PTZ884tbyImlzOzv0mHxbGIziW1tbK1Ty2+ih4wNQTfI2zD0N6Xc5heTAPJAAAAAAElFTkSuQmCC"},{"pckey":"64","fbqpckey":"10","srno":"0000000001","fbqtypepckey":"1","fbchoice":"Exllent","eimg":""},{"pckey":"65","fbqpckey":"10","srno":"0000000002","fbqtypepckey":"1","fbchoice":"Good","eimg":""},{"pckey":"66","fbqpckey":"10","srno":"0000000003","fbqtypepckey":"1","fbchoice":"\u0ba4\u0bae\u0bbf\u0bb4\u0bcd \u0bae\u0bca\u0bb4\u0bbf","eimg":""},{"pckey":"67","fbqpckey":"10","srno":"0000000004","fbqtypepckey":"1","fbchoice":"Can be improved","eimg":""},{"pckey":"68","fbqpckey":"10","srno":"0000000005","fbqtypepckey":"1","fbchoice":"Poor","eimg":""},{"pckey":"69","fbqpckey":"10","srno":"0000000006","fbqtypepckey":"1","fbchoice":"Bad","eimg":""},{"pckey":"74","fbqpckey":"11","srno":"0000000001","fbqtypepckey":"4","fbchoice":"Excellect","eimg":""},{"pckey":"75","fbqpckey":"11","srno":"0000000002","fbqtypepckey":"4","fbchoice":"Good","eimg":""},{"pckey":"76","fbqpckey":"11","srno":"0000000003","fbqtypepckey":"4","fbchoice":"Good","eimg":""},{"pckey":"84","fbqpckey":"12","srno":"0000000001","fbqtypepckey":"2","fbchoice":"Yes","eimg":""},{"pckey":"85","fbqpckey":"12","srno":"0000000002","fbqtypepckey":"2","fbchoice":"No","eimg":""},{"pckey":"86","fbqpckey":"11","srno":"0000000000","fbqtypepckey":"4","fbchoice":"Poor","eimg":""},{"pckey":"87","fbqpckey":"11","srno":"0000000000","fbqtypepckey":"4","fbchoice":"Poor","eimg":""},{"pckey":"88","fbqpckey":"11","srno":"0000000000","fbqtypepckey":"4","fbchoice":"Poor","eimg":""}]"$)
Log(parser.NextArray)
Ok fine Erel. How do i make it work in my app ?
i had changed JOB_DONE as follows :
B4X:
    If Job.Success Then
        Dim res As String
        res = Job.GetString
        Log("Response from server: " & res)
    '    Msgbox("Response from server: " , res)
        Dim parser As JSONParser
        parser.Initialize($"res"$)
result "RuntimeException JSON Array expected."
 
Upvote 0

elitevenkat

Active Member
Licensed User
Longtime User
Yes Erel as usual you are right. There was indeed one echo statement in the php script that caused the issue. Thanks for your time and response.
 
Upvote 0
Top