# Convert HTML table to JSON

**URL:** https://discourse.processing.org/t/convert-html-table-to-json/31555
**Category:** Libraries
**Created:** [August 2, 2021, 10:22pm UTC](https://discourse.processing.org/t/convert-html-table-to-json/31555 "2021-08-02T22:22:55Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mattyjak](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mattyjak/32/16777_2.png) [@Mattyjak](https://discourse.processing.org/u/Mattyjak)
#### Post date: [August 2, 2021, 10:22pm UTC](https://discourse.processing.org/t/convert-html-table-to-json/31555/1 "2021-08-02T22:22:56Z")

</div>

Hello everybody!  
Today I’ve been messing around with APIs and one of the few I’ve tried (Pastebin) returns data in the form of an HTML table. I want to convert this table into a JSON object but I’m having some trouble.

There are online converters but I need something I can access “in-code”.  
I checked the JSONObject’s methods and I don’t see anything that’ll help.

The code I’m using isn’t all that important, but here it is anyways:

```auto
PostRequest post3 = new PostRequest("https://pastebin.com/api/api_post.php");
  addKey(post3);
  post3.addData("api_user_key",api_userKey);
  post3.addData("api_results_limit","5");
  post3.addData("api_option","list");
  post3.send();
  //This here is the returned data:
  print(post3.getContent());
  //I need to convert this to a JSONObject.

```

It’s converting to something like this:

> **Summary**
>
> paste\>  
> \<paste\_key\>adAW23\</paste\_key\>  
> \<paste\_date\>1614664174\</paste\_date\>  
> \<paste\_title\>Script\</paste\_title\>  
> \<paste\_size\>227331\</paste\_size\>  
> \<paste\_expire\_date\>0\</paste\_expire\_date\>  
> \<paste\_private\>1\</paste\_private\>  
> \<paste\_format\_long\>Lua\</paste\_format\_long\>  
> \<paste\_format\_short\>lua\</paste\_format\_short\>  
> \<paste\_url\>[https://pastebin.com/jTZpwNYX](https://pastebin.com/jTZpwNYX)\</paste\_url\>  
> \<paste\_hits\>11\</paste\_hits\>  
> \</paste

---

<div class="post-metadata">

### Author: ![Mattyjak](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mattyjak/32/16777_2.png) [@Mattyjak](https://discourse.processing.org/u/Mattyjak)
#### Post date: [August 2, 2021, 10:24pm UTC](https://discourse.processing.org/t/convert-html-table-to-json/31555/2 "2021-08-02T22:24:22Z")

</div>

Oh, and don’t worry about any keys getting “leaked” 1: It’s all for testing stuff, and 2: I’ve changed them all anyways.
