> Oh that's correct, I don't know how I got valid json last time. I've
> some experience parsing twitter data which had many multiple values
> but for some reason raw parsing of youtube data e.g. with many fields
> named yt$username seems to be hard.
>
> When I tried parse it straight from the data provided by youtube I got
> only null results :S
> as
> data = value["feed"]["yt$username"];
> Only way to even get the first username I needed to parse it first
> value["feed"]["entry"]; and username out of that.
I assume you're actually trying to iterate over the entries and get the
usernames from there.
I don't know how the structure of this library, but you'd want something
like:
for (i=0; i< value["feed"]["entry"].size(); i++) {
std::string username;
username = value["feed"]["entry"][i]["yt$username"]["$t"];
// do something
}
Tim Wintle
> tiistaina 20. maaliskuuta 2012 10.54.01 UTC-5 Mare kirjoitti:
> I'm not quite sure is this right place to ask about this but
> my problem is following:
>
>
> Here is an example feed that I would like to
> parse:https://gdata.youtube.com/feeds/api/users/aniBOOM/subscriptions?v=2&alt=json
>
> You can check it with http://json.parser.online.fr/ to see
> what it contains.
>
> I have a small problem while parsing data feed provided by
> youtube. First issue was the way the youtube provided the data
> wrapped inside feed field and because of that I couldn't parse
> the username straight from original json file so I had to
> parse first entry field and generate new Json data from that.
>
> Anyway the problem is that for some reason that doesn't
> include more than the first username and I don't know why
> because if you check that feed on online parser the entry
> should contain all the usernames.
>
> data = value["feed"]["entry"];
> Json::StyledWriter writer;
> std::string outputConfig = writer.write( data );
> //This removes [ at the beginning of entry and also last ] so we can treat it as a Json data
> size_t found;
> found=outputConfig.find_first_of("[");
> int sSize = outputConfig.size();
> outputConfig.erase(0,1);
> outputConfig.erase((sSize-1),sSize);
>
> reader.parse(outputConfig, value2, false);
>
> cout << value2 << endl;
>
> Json::Value temp;
> temp = value2["yt$username"]["yt$display"];
> cout << temp << endl;
>
> std::string username = writer.write( temp );
> int sSize2 = username.size();
> username.erase(0,1);
> username.erase((sSize2-3),sSize2);
> But for some reason [] fix also cuts the data I'm generating, if I print out the data without removing [] I can see all the users but in that case I can't extract temp = value2["yt$username"]["yt$display"];
>
>
> tiistaina 20. maaliskuuta 2012 10.54.01 UTC-5 Mare kirjoitti:
> I'm not quite sure is this right place to ask about this but
> my problem is following:
>
>
> Here is an example feed that I would like to
> parse:https://gdata.youtube.com/feeds/api/users/aniBOOM/subscriptions?v=2&alt=json
>
> You can check it with http://json.parser.online.fr/ to see
> what it contains.
>
> I have a small problem while parsing data feed provided by
> youtube. First issue was the way the youtube provided the data
> wrapped inside feed field and because of that I couldn't parse
> the username straight from original json file so I had to
> parse first entry field and generate new Json data from that.
>
> Anyway the problem is that for some reason that doesn't
> include more than the first username and I don't know why
> because if you check that feed on online parser the entry
> should contain all the usernames.
>
> data = value["feed"]["entry"];
> Json::StyledWriter writer;
> std::string outputConfig = writer.write( data );
> //This removes [ at the beginning of entry and also last ] so we can treat it as a Json data
> size_t found;
> found=outputConfig.find_first_of("[");
> int sSize = outputConfig.size();
> outputConfig.erase(0,1);
> outputConfig.erase((sSize-1),sSize);
>
> reader.parse(outputConfig, value2, false);
>
> cout << value2 << endl;
>
> Json::Value temp;
> temp = value2["yt$username"]["yt$display"];
> cout << temp << endl;
>
> std::string username = writer.write( temp );
> int sSize2 = username.size();
> username.erase(0,1);
> username.erase((sSize2-3),sSize2);
> But for some reason [] fix also cuts the data I'm generating, if I print out the data without removing [] I can see all the users but in that case I can't extract temp = value2["yt$username"]["yt$display"];
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "YouTube APIs Developer Forum" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/youtube-api-gdata/-/51IpfuvqofgJ.
> To post to this group, send email to
> youtube-api-gdata@googlegroups.com.
> To unsubscribe from this group, send email to youtube-api-gdata
> +unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/youtube-api-gdata?hl=en.
--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment