No iam not using custom written parser.
json_decode function return null when it fetches the field (name: value
pair) "favorited":false.
Since the value false is not written in the double quotes.
As a work around im using $obj->favorited ? 'true' : 'false' , which works.
But im not satisfied with it.
IS there any other better way to do my requirement (to return true/false
without using ternary operator) ?
How shd i handle the fields which has the null values?

Cheers,
Arunachalam

Mob: +91 99 00 56 10 80


On Fri, Jun 26, 2009 at 1:53 PM, Philip Plante <[email protected]>wrote:

>
> You should not experience this if you are using json_decode in php
> (http://us3.php.net/json_decode).  Are you using a custom written
> parser?
>
> On Jun 26, 2:00 am, Arunachalam <[email protected]> wrote:
> > Thank for your input. Iam currently using php JSON praser to decode the
> name
> > value pair,
> > The problem which im facing is that, the parser expect the name valuer
> pair
> > in double quotes eg: "name":"value". But many of the pair in the feed are
> in
> > the format of "favorited":false, in which case i was not able to fetch
> the
> > value of the field.
> > So i consider that, when there is a prefect ordering in the feed i will
> able
> > to guess the next field, and parse accordingly.
> >
> > Cheers,
> > Arunachalam
> >
> > Mob: +91 99 00 56 10 80
> >
> >
> >
> > On Fri, Jun 26, 2009 at 11:15 AM, John Kalucki <[email protected]>
> wrote:
> >
> > > The JSON and XML markup formats do not define a fixed ordering of
> > > their fields and they also allow new fields to be added at any time.
> > > Besides consuming absurd amounts of CPU for name-value pair decoding,
> > > this decoupling of producer and consumer is nearly the entire point of
> > > these markup schemes. If you use a reasonable JSON parser, it will
> > > mask all of these issues for you. If you try to pick the text apart
> > > via other means, you will be continuously reworking as the status
> > > format evolves and as the JSON encoder capriciously reorders its
> > > output.
> >
> > > -John Kalucki
> > > Services, Twitter. Inc.
> >
> > > On Jun 25, 10:13 pm, Arun <[email protected]> wrote:
> > > > Hi all,
> > > > I have few doubts regarding gardenhose feed.
> > > > im redirecting the feed in json into flat file. also using php to
> > > > decode the json format.
> > > > When i went through few records, i was able to see that all records
> > > > are not in same format i.e reply status message format differs from
> > > > the other status format.
> > > > ( few records starts with "created_at" field, while other records
> > > > starts with "favorited"
> > > > I want to know what are the various output record provided by
> > > > gardenhose feed and their respective format and Where do i find the
> > > > same.
> >
> > > > Cheers,
> > > > Arunachalam
>

Reply via email to