Profile / notification

7 views
Skip to first unread message

Tsunaze

unread,
Jul 4, 2011, 5:21:32 PM7/4/11
to Empire Avenue API Discussion
I'm gonna try again, because it's a pretty big problem of json
format .
It happens in the profile/notifications .
And the example i'll show you is simple :

{
type: "earnings"
-info: {
earnings: 45.6
dividends: 4052.94
gains: 0
expenses: 3935.24
shares_bought: 0
shares_bought_user_count: 0
shares_sold: 0
shares_sold_user_count: 0
}
created: "2011-07-04 11:46:17"
}

------

{
type: "mentions"
-info: [
-{
type_id: "twitter"
mentioner_ticker: "LOANS"
mentioner_full_name: "ERICK STROBEL"
}
]
created: "2011-06-10 23:03:02"
}


Those two array are from the same page, but on the "info" section, one
of them is a json object, and one is a json array . And that's the
problem, it creates a lot of problems because we, developers, can't
work with object which got different type (depending on the "type") .
I asked about this a longtime ago but i still haven't heard of
anything .

Duleepa Wijayawardhana

unread,
Jul 4, 2011, 5:34:33 PM7/4/11
to empireave-ap...@googlegroups.com
We'll have a look at it as part of the API 2.0 (now delayed) rollout and get back to you on that. I don't have an answer for you off the top of my head.

Best
Dups

Tsunaze

unread,
Jul 4, 2011, 6:35:40 PM7/4/11
to Empire Avenue API Discussion
thank you .

Kevin Umbach

unread,
Jul 4, 2011, 8:52:34 PM7/4/11
to empireave-ap...@googlegroups.com
Can't you just code around the differences? I did and it works fine.

On Mon, Jul 4, 2011 at 3:21 PM, Tsunaze <galite...@gmail.com> wrote:

Ulf Hedlund

unread,
Jul 4, 2011, 9:53:21 PM7/4/11
to empireave-ap...@googlegroups.com
Guess it depends on the json-library you are using, but it should be
possible to separate the data array and the info object in some easy
way.

Tsunaze

unread,
Jul 5, 2011, 6:12:56 AM7/5/11
to Empire Avenue API Discussion
I use Gson to format json data, that's the problem, but Kevin, when
you say "code around the differences" ? How should i do it ?

kevinu

unread,
Jul 7, 2011, 11:16:56 AM7/7/11
to empireave-ap...@googlegroups.com
I handle the array of notification objects by processing each notification individually. 

For each notification in the returned json
  parse out the "type" field
  if type is equal to "earnings" then 
    parse the remaining notification json as an object
 else if type is equal to "mentions" then
    parse the remaining notification json as an array of objects
  else if type is equal to .....
    parse however is necessary
 end if
end for

Are you even seeing any "mentions" type notifications in the returned json data? I don't recall if they are even working but in my iphone app I just ignore them.


Reply all
Reply to author
Forward
0 new messages