How to parse values from string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Harshpandya
    New Member
    • Jun 2007
    • 30

    How to parse values from string

    I have function that returns this big string and it has all the values i need. How do i do parsing to get each value.

    stdClass Object (
    [cameraConfig] => stdClass Object (
    [videoproperties] => stdClass Object(
    [brightness] => stdClass Object ([mode] => 0 [value] => 20 )
    [contrast] => stdClass Object ( [mode] => 0 [value] => 20 )
    [hue] => stdClass Object ( [mode] => 0 [value] => 20 )
    )


    I want to get the values like brightness and contrast and hue values and also the mode values.

    Example would be great...

    Please help , Thanks
  • vikas251074
    New Member
    • Dec 2007
    • 198

    #2
    You use a unique delimiter to split any text(big or small).

    But you should know what seperates each item. Here suppose comma is a seperator then

    Code:
    var resp = object;
    respArr = resp.split(",");
    // now respArr[0] contains value of "cameraconfig",  respArr[1] contains value of "videoproperties", respArr[2] contains value of  "brightness"  .... and so on.
    This may help you

    Regards,
    Vikas
    Last edited by acoder; Jun 27 '08, 10:30 AM. Reason: fixed code tags

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Yes, split is the method you're looking for and you can use a regular expression too to decide what to split on. However, I'd say it's better to make things easier by getting the function to return something more easily parse-able.

      Comment

      Working...