×

Discussion Board

Results 1 to 5 of 5

Thread: Json parsing

  1. #1
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    224

    Smile Json parsing

    Hi All,

    I wanna to parse Json string, How to get value of tag without passing tag name ?
    I mean to say Json string is not same every time(i.e. tag name will be change everytime) then how can i parse it ?
    For e.g.
    first time my json string is something like this
    Val.Copy(_L("{\"header\":{\"Status\":201,\"Action\":\"auth\",\"UserId\":\"abcd12f\"},\"body\":{\"ConfigVer\":123,\"PIN\":324}}"));
    and next time my json string is something like
    Val.Copy(_L("{\"header\":{\"Status\":201,\"Action\":\"auth\"},\"body\":{\"ConfigVer\":123}}"));
    Please help me...
    Thanks
    Kalgi Modi

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Json parsing


  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,174

    Re: Json parsing

    Did you checked http://wiki.forum.nokia.com/index.ph...e_JSON_string?

    EDIT: Submitted the response simultaneously with savaj's reply. Sorry for that.

  4. #4
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    224

    Re: Json parsing

    Yes, rite now m doing JSON parsing this way.. but i want to parse the value without giving key_name.

    Not like textObj->GetStringL(_L("translatedText"),message); but how can i get the value when i dont know the tag name ?

    jsonBuilder->BuildFromJsonStringL(Val);

    this will parse my Json string , then how can i get the value when JSON tag is not fix (i.e. if tag is changed)??
    Thanks
    Kalgi Modi

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    India
    Posts
    1,174

    Re: Json parsing

    Quote Originally Posted by kalgi View Post
    Yes, rite now m doing JSON parsing this way.. but i want to parse the value without giving key_name.

    Not like textObj->GetStringL(_L("translatedText"),message); but how can i get the value when i dont know the tag name ?

    jsonBuilder->BuildFromJsonStringL(Val);

    this will parse my Json string , then how can i get the value when JSON tag is not fix (i.e. if tag is changed)??
    You don't have any other way instead of recognizing the tag values. If you are having different tag names every time, then this problem can be solved by below method.

    The responses you are receiving should have a particular defined pattern. For example, there can be 10 kinds of pattern that you can receive. Two of them you have already shown (suppose). Now, you should make different classes so that you can parse each kind of response. When you receive pattern1 kind's data, then you should use class1 parser and so on.

    So, from my opinion you should decide what kind of pattern responses you can receive. Then make different classes to parse them by making a parser function which can parse the Json string. On the basis of your request, you should know already in advance what kind of response you will be getting and hence use the corresponding parser class.

Similar Threads

  1. JSON parsing in QT?
    By sindhuks in forum Qt
    Replies: 7
    Last Post: 2011-03-29, 22:44
  2. JSON
    By atonical in forum Qt
    Replies: 1
    Last Post: 2010-10-09, 08:20
  3. 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
  4. JSON Parsing
    By raja_salomo in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2009-09-25, 08:50
  5. json?!
    By programer_asal in forum Symbian
    Replies: 4
    Last Post: 2009-06-05, 02:50

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×