Extract data from a HTML table and convert to JSON
Here is an answer using Jsoup and JSON as dependencies: Output (formatted):
Technical answers from my Stack Overflow history, with source links and licenses.
Showing 7 of 7 answers tagged json
Exported May 9, 2026
Here is an answer using Jsoup and JSON as dependencies: Output (formatted):
You can parse JSON keys with whitespace with Gson by using SerializedName annotation. Example:
Possible solution: Testing with your example JSON string: Output: Note: This is not ideal and I just wrote it real quick.
You are using getString on "ID" when you should be using getInt . I tested the JSON string you provided in your question. The following code works: Output from running the above code: id=4, name='Vinoth',...
If I understand correctly, you want the output to be like the second JSON array in your question. Changing where you loop should do the trick: I tested with the input you have. Here is the formatted JSON output:
Are you sure you are using the same jar in both projects? Android's org.json.JSONObject.toString(String) is different: JSON.toString(Object) : In your case this would not throw an exception on Android.
For something that simple I don't think adding Gson as a dependency is worth it. Example: