I am doing something wrong with json - help

I tried two different sunrise/sunset api's. The one in the blocks below is a Dept of Homeland Sec (TSA).
I get a response that the json returned is not formatted correctly. When I send the query from my browser address bar, the site returns the correct info. Also, if I ask for an XML rather than a json response, I am also told that the XML is not formatted correctly. The api site and my aia are below the blocks picture:

photon.aia (2.2 KB)


If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...

To download the aia file, upload it to App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...
Thank you.


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Looks like you are combining two different request syntaxes, specific date and JSON option.

The responseContent looks more like XML than JSon, but it does not decode well.

Here is a working XML based solution.
I had to convert (backslash)" to " to get the XML parseable.
I could not get JSON output, though I did not try very hard.
photon_ABG.aia (4.6 KB) Working XML

corrected XML
Unparseable xml:

Do It Result: ""<?xml version=\"1.0\" encoding=\"utf-8\"?><EventInfo xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Sunrise>05:55:21 AM</Sunrise><Sunset>08:13:41 PM</Sunset></EventInfo>""

Further thoughts on the lack of json output:

I notice that the URL samples provided have their parameters given in the order
[valid parameters: eventtype, eventdate, airportcode, lat, lon, utc, dst, output]

Maybe that is necessary?

That's great. Thank you. Are the (") returned istead of (") just bad XML or is it bad AppInventor ?

Good question.
Quotes of quotes is a mess, and I would rather not think about it.

I finally managed to decode the json. The site I got the data from was returning a json with extra stuff at the start and end. I stripped that off and decoded what remained to a list of pairs. Thanks.