|
| 24 Oct 2015 01:25 PM |
HS = game:GetService("HttpService") test = HS:GetAsync("http://example.com", true) new = HS:JSONDecode(test) print(new)
If I don't use JSONDecode and I print test, it gives me the HTML layout of the page. If I use JSONDecode, output says "Can't parse JSON" and this code is via command bar in studio. I used JSONDecode to get rid of the HTML code and just give me the text of the page (I'm assuming that's what JSONDecode does) but like I said, it gave me that error. I'm new to HTTPService too so I'm not absolutely familiar with these things. |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2015 01:30 PM |
remove all HTML code from page so when you go to the website it looks like this
[{"team":"a","pts":"0"},{"team":"b","pts":"0"},{"team":"c","pts":"0"},{"team":"d","pts":"0"}]
html is not needed |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2015 01:35 PM |
also the php should have something like this
echo json_encode($results); |
|
|
| Report Abuse |
|
|
|
| 24 Oct 2015 02:11 PM |
JSONDecode assumes that strings fed to it are formatted as strict JSON. It will throw an error if you pass it the source of an HTML file (e.g. in your code).
In the same respect, JSONDecode will not automatically find and parse JSON data in a string that also contains non-JSON data. |
|
|
| Report Abuse |
|
|