0

No Spaces in Keys

Avoiding spaces in return value keys, makes it easier to navigate with specially javascript. An example is "Place Type".

While something like

jsonreturn.place.centroid.latitude is easier to use,

y.place.placeTypeName attrs.code is wrong.

It has to be written as

y.place['placeTypeName attrs'].code

Avoiding spaces makes it easier to navigate through the returned object.

by
2 Replies
  • QUOTE (Ravindranath A @ Mar 30 2010, 06:18 AM) <{POST_SNAPBACK}>
    Avoiding spaces in return value keys, makes it easier to navigate with specially javascript. An example is "Place Type".

    While something like

    jsonreturn.place.centroid.latitude is easier to use,

    y.place.placeTypeName attrs.code is wrong.

    It has to be written as

    y.place['placeTypeName attrs'].code

    Avoiding spaces makes it easier to navigate through the returned object.


    Thanks for reminding JavaScript users to use array notation rather than object notation to fetch attributes such as the placeTypeName code attribute. This is a consequence of mapping XML attributes to JSON elements. Unfortunately, we can't change the JSON response format now without breaking things for existing users.

    Eddie Babcock
    Yahoo! Geo Technologies
    0
  • QUOTE (Eddie B @ Apr 1 2010, 08:21 AM) <{POST_SNAPBACK}>
    Thanks for reminding JavaScript users to use array notation rather than object notation to fetch attributes such as the placeTypeName code attribute. This is a consequence of mapping XML attributes to JSON elements. Unfortunately, we can't change the JSON response format now without breaking things for existing users.

    Eddie Babcock
    Yahoo! Geo Technologies


    I agree the response should be kept consistent. Nevertheless, I hope the notation I included here would help others using json calls. Finally, Yahoo Geo Team did an amazing job with Geo Data. We love it!
    0
This forum is locked.

Recent Posts

in GeoPlanet General Discussion