Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert String array to json in android

Tags:

android

I have a problem. I want to pass String array to javascript, but this is impossible, so I want to convert String array to json and send it to java script. How can I do that?

like image 895
edi233 Avatar asked Dec 29 '25 17:12

edi233


1 Answers

Just convert use JSONArray,

import java.util.Arrays;
import org.json.JSONArray;
String[] inputs = new String[] {"foo", "bar"};
JSONArray jsonArray = new JSONArray(Arrays.asList(inputs));
like image 165
Qiang Jin Avatar answered Jan 01 '26 07:01

Qiang Jin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!