Getting data values from json object

1 view
Skip to first unread message

tes...@netcarnation.com

unread,
Apr 30, 2009, 7:00:31 AM4/30/09
to Orkut Developer Forum
hi,

example:

{
friends : [
{
name: 'David',
interests: 'Cooking',
},
{
name: 'Charles',
interests: 'Hiking',
},
{
name: 'Mary',
interests: 'Football',
},
]
}

By referring to Open Social Templates Developers's Guide in 'Fetching
data from a URL ' section the above example is copied to a file and
uploaded to server, and using <os:HttpRequest> tag like,

<os:HttpRequest key="friends" href="http://www.servername/foldername/
filename" authz="signed" refreshInterval="1" />

and by using " <li repeat="${friends}"> " data is iterated and the i
tried to print the values for name and interests which gives result
'blank'.

As ${Cur.name} and ${Cur.interests} is displayed blank and i tried to
give as ${friends.content.friends.name} and :$
{friends.content.friends.interests} to get values for name and
interests but even this displayed as 'blank'.

how to get values for name and interests of all 3 rows from the file
which is uploaded to server?

reg,
Arun.







eduardorochabr

unread,
Apr 30, 2009, 1:15:38 PM4/30/09
to Orkut Developer Forum
I was only successful using the following, including the ".content"
part, after debuging using this tip (item #8):

http://groups.google.com/group/opensocial-orkut/tree/browse_frm/thread/e7d1632bd6eb79ef/2471916f249307ba?rnum=1&_done=%2Fgroup%2Fopensocial-orkut%2Fbrowse_frm%2Fthread%2Fe7d1632bd6eb79ef%2F32d418c790228727%3Fq%3D%26#doc_76eeba8c1a954e6a.

<li repeat="${osx:parseJson(friends.content)}">

Since I am not sure about your actualy JSON structure, try this too:

<li repeat="${osx:parseJson(friends.content).friends)}">
\ \- json variable
\- data pipeline variable

Remember to declare the osx namespace:

<script type="text/os-template" xmlns:os="http://ns.opensocial.org/
2008/markup" xmlns:osx="http://ns.opensocial.org/2009/extensions">

Let me know if it works.

On 30 abr, 08:00, "test...@netcarnation.com"

Paresh Joshi

unread,
Apr 30, 2009, 1:45:41 PM4/30/09
to Orkut Developer Forum
Arun,
Debugging tip by eduardo helped me resolve the issue.
Please check the post:
http://groups.google.com/group/opensocial-orkut/browse_thread/thread/26d36d2d6ff98cfb
Thanks,
Paresh

On Apr 30, 10:15 am, eduardorochabr <eduardoroch...@gmail.com> wrote:
> I was only successful using the following, including the ".content"
> part, after debuging using this tip (item #8):
>
> http://groups.google.com/group/opensocial-orkut/tree/browse_frm/threa....

eduardorochabr

unread,
Apr 30, 2009, 1:58:12 PM4/30/09
to Orkut Developer Forum
Actually, debugging the app once again, I think we don't need to use
parseJson, it comes already parsed. So that would become:

<li repeat="${songs.content.songs}">
\ \- json variable
\- data pipeline variable

On 30 abr, 14:45, Paresh Joshi <pareshjosh...@gmail.com> wrote:
> Arun,
> Debugging tip by eduardo helped me resolve the issue.
> Please check the post:http://groups.google.com/group/opensocial-orkut/browse_thread/thread/...

arun

unread,
May 4, 2009, 5:24:56 AM5/4/09
to Orkut Developer Forum
hi thanks, it worked out fine with

<li repeat="${songs.content.songs}"> .

here the format attribute is defaultly 'json' and not 'text', if the
data in file present in server is in xml form, how can i retrieve xml
data and display element values?

reg,
Arun
Reply all
Reply to author
Forward
0 new messages