By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,045 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,045 IT Pros & Developers. It's quick & easy.

How to parse values from string

P: 30
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
Jun 26 '08 #1
Share this Question
Share on Google+
2 Replies


vikas251074
100+
P: 198
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

Expand|Select|Wrap|Line Numbers
  1. var resp = object;
  2. respArr = resp.split(",");
  3. // now respArr[0] contains value of "cameraconfig",  respArr[1] contains value of "videoproperties", respArr[2] contains value of  "brightness"  .... and so on.
  4.  
This may help you

Regards,
Vikas
Jun 27 '08 #2

acoder
Expert Mod 15k+
P: 16,027
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.
Jun 27 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.