Discussion Board

Results 1 to 14 of 14

Thread: QML JSON parser

  1. #1
    Regular Contributor waelfarouk's Avatar
    Join Date
    Jan 2009
    Posts
    171
    Hi,
    I am looking for QML json parser and display result on list on QML page


    can you advice me with a good example


    Thanks
    Wael

  2. #2
    Registered User manikantan's Avatar
    Join Date
    Apr 2008
    Location
    India / Singapore
    Posts
    549
    Here is a JSON parser written in Javascript.

    INclusion of the JS file and an example is below..
    http://developer.qt.nokia.com/forums/viewthread/2057
    Twitter - manikantan_k
    Just in --

  3. #3
    Regular Contributor waelfarouk's Avatar
    Join Date
    Jan 2009
    Posts
    171
    Hi,
    Thanks
    but where to find file parser.js
    import "parser.js" as JS

    Or do i have to get json javascript from json.org


    thanks




    Quote Originally Posted by waelfarouk View Post
    Hi,
    I am looking for QML json parser and display result on list on QML page


    can you advice me with a good example


    Thanks
    Wael

  4. #4
    Regular Contributor waelfarouk's Avatar
    Join Date
    Jan 2009
    Posts
    171
    @manikantan
    Thanks

    Link example worked


    Quote Originally Posted by waelfarouk View Post
    Hi,
    Thanks
    but where to find file parser.js
    import "parser.js" as JS

    Or do i have to get json javascript from json.org


    thanks

  5. #5
    Nokia Developer Champion kkrish's Avatar
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,029
    Quote Originally Posted by waelfarouk View Post
    @manikantan
    Thanks

    Link example worked
    Hi,

    how does it work for you? can you please help?

  6. #6
    Nokia Developer Champion gaba88's Avatar
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,701
    Hello KKrish,

    I guess you dont need to have dependencies with help of javascript eval method, json parsing is readily supported in the box.

    so you can try something like:

    var jsonObject = eval('(' + testToparse + ')');

    which will return a list or a dict and than you can iterate over that to get what you want.

    Let me know if you need a working example. :-)

  7. #7
    Nokia Developer Champion kkrish's Avatar
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,029
    Will it work on emulator?

    getting error on on qtSDK 1.2 emulator "Result of expression 'jsonObject.flux' [undefined] is not an object"

  8. #8
    Regular Contributor waelfarouk's Avatar
    Join Date
    Jan 2009
    Posts
    171
    Quote Originally Posted by kkrish View Post
    Will it work on emulator?

    getting error on on qtSDK 1.2 emulator "Result of expression 'jsonObject.flux' [undefined] is not an object"
    Yes it will work on emulator

  9. #9
    Nokia Developer Champion kkrish's Avatar
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,029
    anything need to import for it?

  10. #10
    Nokia Developer Champion gaba88's Avatar
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,701
    can you show the code you are trying its working good on my side and you dont need to import anything new.

  11. #11
    Nokia Developer Champion kkrish's Avatar
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,029
    xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState === 4) {
    if (xmlhttp.status === 200) {
    var jsonObject = eval('(' + xmlhttp.responseText + ')');
    for ( var index in jsonObject.flux.all )
    {
    console.log(jsonObject.flux.all[index].data["title"]);
    console.log(jsonObject.flux.all[index].data["content"]);
    }
    } else {
    console.log("responseText", xmlhttp.responseText);
    }
    }
    }

  12. #12
    Nokia Developer Champion kkrish's Avatar
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,029
    it is done. just going through with the json document and how we can access the element from json object.

  13. #13
    Registered User felipecrochik's Avatar
    Join Date
    Jun 2009
    Posts
    42
    QML includes a "JSON" parser. Instead of using eval use JSON.parse.... No need to include or import anything...

  14. #14
    Nokia Developer Champion kkrish's Avatar
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,029
    Quote Originally Posted by felipecrochik View Post
    QML includes a "JSON" parser. Instead of using eval use JSON.parse.... No need to include or import anything...
    Hi,

    Thanks for the reply. Problem is already solved.

Similar Threads

  1. How to use Json Parser
    By poojs in forum Symbian C++
    Replies: 17
    Last Post: 2010-07-06, 07:45
  2. How to download JSON ME Api "org.json.me.zip"
    By narendar_discover in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2010-05-01, 12:15
  3. JSON
    By danhicksbyron in forum Qt
    Replies: 1
    Last Post: 2010-04-15, 06:06
  4. kXML XML Parser versus Jsr172 API Parser
    By javame.developer in forum Mobile Java General
    Replies: 1
    Last Post: 2008-02-14, 20:23
  5. xhtml parser & xml parser
    By indvin in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2005-08-25, 13:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved