How do I can read a external JSON or XML file?

0 favourites
From the Asset Store
Source File, music and art pack for Android Negotiator
  • Hi guys.

    I've found an API for a MMORPG.

    This site distribute an API in this format

    census.soe.com/s:example/json/get/ps2:v2/character

    or

    census.soe.com/s:example/xml/get/ps2:v2/character

    How can i take this content and read in my app?

    Thanks so much for all

  • UP

    No one can help me?

  • I would recommend the xml option. You can do this with the AJAX object and the XML object. You can read the tutorials here:

    https://www.scirra.com/manual/139/xml

    https://www.scirra.com/manual/107/ajax

  • I've just tried with this two tutorial.

    But didn't work.

    Someone can try and post correct code pls?

  • UP

  • Hmm do you know you can convert the JSON file to CSV using json-csv.com...maybe that would be easier to work with.

  • There are more than one API in this site.

    And i need send some informations on input...

    I can't use CSV

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes i've read but it's usless.

    I don't want download file from the website.

  • Your choice not mine. If one wants to learn he or she would do anything. In your case sorry no comment

  • I'm here for learn but the tutorials can't help me.

    How can i learn it if the guide is incomplete?

    And you talk and write but do nothing for help me.

  • you only help those whom help them self. there are example on forum to read and learn. Ask Ashley, Moderator kyatric

  • danju92: you can't expect that somebody will code it for you. You have to read the forum, download and try the samples and ask specific questions. (Like what is not working or there is an error) Also a sample what you have would be nice, so it's easier to find the mistake. In this forum you get tips and hints what you have to do, but programming you have to do it yourself. Beside that if you are more polite, maybe you will get more help.

    What you are looking is not help, but rather a programmer. I recommend you should check this:

  • edwardr thanks for making it clear

  • I think what he is having trouble with, is getting the game to read a json or xml file from an external server(url). An issue I was having as well at one point. By default, browsers are set to block those request, so you have to give that permission manually.

    I think this is what your after? Copied from tutorial.

    Making AJAX requests cross-domain or in preview

    By default, browsers block AJAX requests across domains. This means, for example, a game on scirra.com can request other pages on scirra.com, but cannot request pages on facebook.com. This is an important security feature of web browsers (it is not specific to Construct 2 or its AJAX object).

    Also, when previewing in Construct 2 the game runs on localhost. This counts as a different domain to the rest of the internet, so typically AJAX requests to any web page will fail during preview, unless the server explicitly allows cross-domain requests.

    *** (this part is the trouble. Lack of explanation here down)****

    If you want AJAX requests to your server to work from any domain, or in preview, you can configure it to send the following HTTP header:

    Access-Control-Allow-Origin: *

    This will enable AJAX requests from any domain, but you should still be aware of the possible security implications of this. For more information on cross-domain requests see HTTP access control on MDN.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)