Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
169
rated 0 times [  171] [ 2]  / answers: 1 / hits: 24570  / 12 Years ago, mon, july 9, 2012, 12:00:00

I am working with an android app that uses phonegap. The java calls some HTML that displays a web page and the HTML uses javascript for functions. Now in the javascript I make a JSON call using parameters from the HTML. The problem is I need to send this JSONArray back to the Java class. However, when I use



JavaActivity.parseJson(jsonArray.toString());


(where jsonArray is the JSONArray and parseJson is the method in the java activity)



the string that it sends looks something like this:



[{Object:Object}, {Object:Object}, {Object:Object}, .....]


What am I doing wrong or is there another way to convert this String, or just send the JSONArray directly?


More From » java

 Answers
2

Assuming jsonArray holds all the data you want to send to Java do:



var jString = JSON.stringify(jsonArray);


Now 'jString' is the json encoded string representation of your array.


[#84375] Saturday, July 7, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alysas

Total Points: 616
Total Questions: 111
Total Answers: 124

Location: Slovenia
Member since Wed, Apr 6, 2022
2 Years ago
alysas questions
Sun, Jul 19, 20, 00:00, 4 Years ago
Tue, Jun 23, 20, 00:00, 4 Years ago
Mon, Mar 30, 20, 00:00, 4 Years ago
;