generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Issue with JSONDecode

Previous Thread :: Next Thread 
TheBenSquare is not online. TheBenSquare
Joined: 13 Dec 2009
Total Posts: 13604
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
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
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
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
24 Oct 2015 01:35 PM
also the php should have something like this

echo json_encode($results);
Report Abuse
fractality is not online. fractality
Joined: 18 Nov 2008
Total Posts: 824
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image