Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › How do I convert an XML to JSON

Tagged: , , , ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #19019

    Daniel Tapia

    The API I’m using only returns all calls in an XML format. I would like to convert it into a JSON format.

    Please show an example if possible. Thank you!

    #19021

    Javier

    Hi,

     

    I do not know if this can be directly done in QML or Felgo, but you can define a C++ class or a JavaScript function to do so. Here you can find a JavaScript function, https://gist.github.com/chinchang/8106a82c56ad007e27b1

     

    I have not tested It, so let us know if it works for you.

    #19045

    Günther
    Felgo Team

    Hi,

    Felgo does not provide a quick way of converting XML to JSON. If possible, it’s easiest if your API already return JSON objects from the start.

    If you are going to use the returned XML data for display in your views, you can have also have a look at the XmlListModel type. You can use it to fill your UI based on XML data instead of a JSON-structure when working with model-delegate based UI components. (e.g. AppListView, Repeater, …)

    Best,
    Günther

    #19052

    Daniel Tapia

    Yes I finally got XML data to come back. Which component will work best to return the data model the way I want to. Like for an example I want just the last data from the model… Would I be able to view some code snippets… Thanks!

    #19060

    Günther
    Felgo Team
Viewing 5 posts - 1 through 5 (of 5 total)

RSS feed for this thread

You must be logged in to reply to this topic.