SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: parsing json

  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    parsing json

    I am new to parsing Json objects and I want to ask this question.
    I have this xml that I use it now as data used by ajax.
    Code:
    <selectChoice>
    <entry>
    <optionText>--Select--</optionText>
    <optionValue>-2</optionValue>
    </entry>
    <entry>
    <optionText>my</optionText>
    <optionValue>35</optionValue>
    </entry>
    </selectChoice>
    As I read, json is far more quick, so I want to convert it to Json.
    My problem is how to create the multiple entry values.
    How will be the json file for this xml?
    And a second question, how I will do a loop reading the entry values of the json from javascript?
    Readind one element is known but I do not know the loop.
    I will use prototype.js

  2. #2
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dimis283 View Post
    I am new to parsing Json objects and I want to ask this question.
    I have this xml that I use it now as data used by ajax.
    Code:
    <selectChoice>
    <entry>
    <optionText>--Select--</optionText>
    <optionValue>-2</optionValue>
    </entry>
    <entry>
    <optionText>my</optionText>
    <optionValue>35</optionValue>
    </entry>
    </selectChoice>
    As I read, json is far more quick, so I want to convert it to Json.
    My problem is how to create the multiple entry values.
    How will be the json file for this xml?
    ie
    PHP Code:
    [{"text":"--Select--","value":"2"},{"text":"my","value":"35"}] 
    And a second question, how I will do a loop reading the entry values of the json from javascript?
    Readind one element is known but I do not know the loop.
    simply with a for statement

    take a look at http://www-128.ibm.com/developerwork...ex.html#list10


    Bye.


Bookmarks

Posting Permissions

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