0

I am reading data from my database using PHP and I get the result by using echo which I read inside my java code.

The result from my string is as follows:

String mydata;
mydata = "["sdfsd_-sdf","gdf5g7_","fsdfl50","sdfsf_5-X"]"

I had like to split it into array as get this result (without quotes sign):

array[0] = sdfsd_-sdf
array[1] = gdf5g7_
array[2] = fsdfl50
array[3] = sdfsf_5-X

I have used this code to do it:

String[] my_array = mydata.split(",");

However my result is:

array[0] = "["sdfsd_-sdf""
array[1] = ""gdf5g7_""
array[2] = ""fsdfl50""
array[3] = ""sdfsf_5-X"]"

How can i get rid of the ] [ and "?

Thank you

benb
  • 351
  • 1
  • 2
  • 7
  • 1
    1) `myData = myData.subString(1, myData.length() - 1)`. 2) `array[x] = array[x].subString(1, myData.length() - 1)`. – Seelenvirtuose Sep 14 '19 at 09:39
  • If this is JSON which you are passing then I would have thought https://stackoverflow.com/questions/16574482/decoding-json-string-in-java would be what your after. – Nigel Ren Sep 14 '19 at 10:08
  • It is indeed a json that I obtain from my PHP 'echo json_encode($rows)' however when I obtain it in my java doInBackground task it is returned as string – benb Sep 14 '19 at 10:10

0 Answers0