-2

I know there are many topics about this subject but I think all of them have got old because all of them have been written something like this: JSONArray jsonArray = new JSONArray(String variable); .

Now JSONArray's constructor gets just int value as capacity or gets nothing.

So with this new JSONArray method how can I convert String to JsonArray? This is my String: ["https://serverv2.nokhbgan.ir/api/Products/DownloadFileV1?src=NGrvxefUHed_1.png","https://serverv2.nokhbgan.ir/api/Products/DownloadFileV1?src=NGrvxefUHed_2.png"]

1 Answers1

0

JSONArray and JsonArray are two different class one from package org.json; and other from package com.google.gson;

JSONArray Do have the constructor which takes a string as input on the other hand JsonArray from google's Gson library don't.

I think you are suppose to use JSONArray but mistakenly imported JsonArray because you might be using gson library for some json parsing.

Note: Always make sure to double confirm the import to see what class you are using because many time they have exact same name, at least in this case the alphabets cases were different, but you can find the classes to be having exact same name and everything so please confirm whether you are using a correct intended class or not, this may be use cause of time waste many times.

Dinkar Kumar
  • 2,175
  • 2
  • 12
  • 22