You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by "Gonzalo Aune (JIRA)" <ji...@apache.org> on 2008/07/23 17:01:31 UTC

[jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

     [ https://issues.apache.org/jira/browse/SHINDIG-469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gonzalo Aune updated SHINDIG-469:
---------------------------------

    Attachment: canonicaldb-fix.patch

This is the patch fixing the db.json, it seems like it doesnt accept comments, and there are a couple of errors in some lines with an extra "," like:

"body" : "what a color!",

and 

"unstructuredAddress" : "1 Edu St.",

The patch fix these lines and removes the comments, without these changes, PHP json function doesnt decode the string. Is there any possibilities to commit this and add the comments in an README file?

G.-

> Error parsing canonicaldb.json in PHP
> -------------------------------------
>
>                 Key: SHINDIG-469
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-469
>             Project: Shindig
>          Issue Type: Bug
>          Components: RESTful API (Java), RESTful API (PHP)
>            Reporter: Gonzalo Aune
>         Attachments: canonicaldb-fix.patch
>
>
> I had a couple of errors trying to decode the json db in PHP, it simply dont parse.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Ropu <ro...@gmail.com>.
Agree with that.

as the second choice before sending a JsonMalformedException()

ropu

On Thu, Jul 24, 2008 at 1:42 PM, Louis Ryan <lr...@google.com> wrote:

> Sure, by all means remove the trailing commas (not the whole line though!).
> The point is really whether the PHP code can handle theoretically JSON
> compliant strings that have this problem in the restful API. Having a RegEx
> to strip them if your parse fails may be a reasonable fallback and retry
> procedure if you felt so inclined.
>
> On Thu, Jul 24, 2008 at 7:10 AM, Gonzalo Aune <go...@gmail.com>
> wrote:
>
> > Definitely the complex RegEx isnt the solution at all =), that will take
> a
> > lot of time if the db grows and grows or if we need another .json file
> with
> > lot of information.... and definitely the solution as you mention above
> is
> > to removes those lines.
> >
> > G.-
> >
> > On Thu, Jul 24, 2008 at 11:00 AM, Ropu <ro...@gmail.com> wrote:
> >
> > > maybe a complex RegEx can detect and remove the trailing ','
> > >
> > > still, is easier and more efficient to just "dont put it"
> > > ropu
> > >
> > > On Thu, Jul 24, 2008 at 10:58 AM, Gonzalo Aune <go...@gmail.com>
> > > wrote:
> > >
> > > > In the examples of the json spec (http://tools.ietf.org/html/rfc4627
> ),
> > > he
> > > > never leaves an extra comma after the strings or objects, but in our
> > > > canonicaldb.json we are doing it:
> > > >
> > > >    "john.doe" : [{
> > > >      "id" : "1",
> > > >      "userId" : "john.doe",
> > > >      "title" : "yellow",
> > > >      "body" : "what a color!",           --->HERE!
> > > >    }],
> > > >
> > > >    "schools" : [{
> > > >      "address" : {
> > > >        "unstructuredAddress" : "1 Edu St.",      ----->HERE!
> > > >      },
> > > >      "description" : "High School",
> > > >      "endDate" : "1991-01-01",
> > > >      "field" : "",
> > > >      "name" : "",
> > > >      "salary" : "",
> > > >      "startDate" : "1982-01-01",
> > > >      "subField" : "",
> > > >      "title" : "",
> > > >      "webpage" : ""
> > > >      }],
> > > >
> > > > This is what i meant before... can we only fix this and i'll remove
> the
> > > > comments with regexp ?
> > > >
> > > > G.-
> > > >
> > > > On Wed, Jul 23, 2008 at 4:03 PM, Chris Chabot <ch...@xs4all.nl>
> > wrote:
> > > >
> > > > > On Jul 23, 2008, at 8:28 PM, Louis Ryan wrote:
> > > > >
> > > > >  We could though technically the extra ',' is allowed by the JSON
> > spec
> > > > and
> > > > >> there's a reasonable chance you'll get JSON with these artifacts
> > > coming
> > > > in
> > > > >> from 3rd parties on the RESTful API.  What are the library options
> > on
> > > > the
> > > > >> PHP side to have a more tolerant parser.
> > > > >>
> > > > >
> > > > > We certainly did experiment with this, but the only viable
> > (production
> > > > > ready) solution is a metric ton of native php code, which is 10000x
> > > > slower,
> > > > > slows down the QPM severely (due to the way apache/php loads in the
> > > code
> > > > on
> > > > > every request) and crashing on other particularities again, in
> other
> > > > words
> > > > > not so terribly much :)
> > > > >
> > > > >
> > > > >  For comments we can certainly adopt a convetion to use comments on
> > > > >> newlines
> > > > >> only within Shindig if that helps.
> > > > >>
> > > > >
> > > > > Nah comments are no problem, all we need to do is strip them from
> the
> > > > > content before parsing it, not optimal but certainly not so bad
> that
> > i
> > > > would
> > > > > want to try to enforce such rules.
> > > > >
> > > > >        -- Chris
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > .-. --- .--. ..-
> > > R o p u
> > >
> >
>



-- 
.-. --- .--. ..-
R o p u

Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Louis Ryan <lr...@google.com>.
Sure, by all means remove the trailing commas (not the whole line though!).
The point is really whether the PHP code can handle theoretically JSON
compliant strings that have this problem in the restful API. Having a RegEx
to strip them if your parse fails may be a reasonable fallback and retry
procedure if you felt so inclined.

On Thu, Jul 24, 2008 at 7:10 AM, Gonzalo Aune <go...@gmail.com> wrote:

> Definitely the complex RegEx isnt the solution at all =), that will take a
> lot of time if the db grows and grows or if we need another .json file with
> lot of information.... and definitely the solution as you mention above is
> to removes those lines.
>
> G.-
>
> On Thu, Jul 24, 2008 at 11:00 AM, Ropu <ro...@gmail.com> wrote:
>
> > maybe a complex RegEx can detect and remove the trailing ','
> >
> > still, is easier and more efficient to just "dont put it"
> > ropu
> >
> > On Thu, Jul 24, 2008 at 10:58 AM, Gonzalo Aune <go...@gmail.com>
> > wrote:
> >
> > > In the examples of the json spec (http://tools.ietf.org/html/rfc4627),
> > he
> > > never leaves an extra comma after the strings or objects, but in our
> > > canonicaldb.json we are doing it:
> > >
> > >    "john.doe" : [{
> > >      "id" : "1",
> > >      "userId" : "john.doe",
> > >      "title" : "yellow",
> > >      "body" : "what a color!",           --->HERE!
> > >    }],
> > >
> > >    "schools" : [{
> > >      "address" : {
> > >        "unstructuredAddress" : "1 Edu St.",      ----->HERE!
> > >      },
> > >      "description" : "High School",
> > >      "endDate" : "1991-01-01",
> > >      "field" : "",
> > >      "name" : "",
> > >      "salary" : "",
> > >      "startDate" : "1982-01-01",
> > >      "subField" : "",
> > >      "title" : "",
> > >      "webpage" : ""
> > >      }],
> > >
> > > This is what i meant before... can we only fix this and i'll remove the
> > > comments with regexp ?
> > >
> > > G.-
> > >
> > > On Wed, Jul 23, 2008 at 4:03 PM, Chris Chabot <ch...@xs4all.nl>
> wrote:
> > >
> > > > On Jul 23, 2008, at 8:28 PM, Louis Ryan wrote:
> > > >
> > > >  We could though technically the extra ',' is allowed by the JSON
> spec
> > > and
> > > >> there's a reasonable chance you'll get JSON with these artifacts
> > coming
> > > in
> > > >> from 3rd parties on the RESTful API.  What are the library options
> on
> > > the
> > > >> PHP side to have a more tolerant parser.
> > > >>
> > > >
> > > > We certainly did experiment with this, but the only viable
> (production
> > > > ready) solution is a metric ton of native php code, which is 10000x
> > > slower,
> > > > slows down the QPM severely (due to the way apache/php loads in the
> > code
> > > on
> > > > every request) and crashing on other particularities again, in other
> > > words
> > > > not so terribly much :)
> > > >
> > > >
> > > >  For comments we can certainly adopt a convetion to use comments on
> > > >> newlines
> > > >> only within Shindig if that helps.
> > > >>
> > > >
> > > > Nah comments are no problem, all we need to do is strip them from the
> > > > content before parsing it, not optimal but certainly not so bad that
> i
> > > would
> > > > want to try to enforce such rules.
> > > >
> > > >        -- Chris
> > > >
> > >
> >
> >
> >
> > --
> > .-. --- .--. ..-
> > R o p u
> >
>

Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Gonzalo Aune <go...@gmail.com>.
Definitely the complex RegEx isnt the solution at all =), that will take a
lot of time if the db grows and grows or if we need another .json file with
lot of information.... and definitely the solution as you mention above is
to removes those lines.

G.-

On Thu, Jul 24, 2008 at 11:00 AM, Ropu <ro...@gmail.com> wrote:

> maybe a complex RegEx can detect and remove the trailing ','
>
> still, is easier and more efficient to just "dont put it"
> ropu
>
> On Thu, Jul 24, 2008 at 10:58 AM, Gonzalo Aune <go...@gmail.com>
> wrote:
>
> > In the examples of the json spec (http://tools.ietf.org/html/rfc4627),
> he
> > never leaves an extra comma after the strings or objects, but in our
> > canonicaldb.json we are doing it:
> >
> >    "john.doe" : [{
> >      "id" : "1",
> >      "userId" : "john.doe",
> >      "title" : "yellow",
> >      "body" : "what a color!",           --->HERE!
> >    }],
> >
> >    "schools" : [{
> >      "address" : {
> >        "unstructuredAddress" : "1 Edu St.",      ----->HERE!
> >      },
> >      "description" : "High School",
> >      "endDate" : "1991-01-01",
> >      "field" : "",
> >      "name" : "",
> >      "salary" : "",
> >      "startDate" : "1982-01-01",
> >      "subField" : "",
> >      "title" : "",
> >      "webpage" : ""
> >      }],
> >
> > This is what i meant before... can we only fix this and i'll remove the
> > comments with regexp ?
> >
> > G.-
> >
> > On Wed, Jul 23, 2008 at 4:03 PM, Chris Chabot <ch...@xs4all.nl> wrote:
> >
> > > On Jul 23, 2008, at 8:28 PM, Louis Ryan wrote:
> > >
> > >  We could though technically the extra ',' is allowed by the JSON spec
> > and
> > >> there's a reasonable chance you'll get JSON with these artifacts
> coming
> > in
> > >> from 3rd parties on the RESTful API.  What are the library options on
> > the
> > >> PHP side to have a more tolerant parser.
> > >>
> > >
> > > We certainly did experiment with this, but the only viable (production
> > > ready) solution is a metric ton of native php code, which is 10000x
> > slower,
> > > slows down the QPM severely (due to the way apache/php loads in the
> code
> > on
> > > every request) and crashing on other particularities again, in other
> > words
> > > not so terribly much :)
> > >
> > >
> > >  For comments we can certainly adopt a convetion to use comments on
> > >> newlines
> > >> only within Shindig if that helps.
> > >>
> > >
> > > Nah comments are no problem, all we need to do is strip them from the
> > > content before parsing it, not optimal but certainly not so bad that i
> > would
> > > want to try to enforce such rules.
> > >
> > >        -- Chris
> > >
> >
>
>
>
> --
> .-. --- .--. ..-
> R o p u
>

Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Ropu <ro...@gmail.com>.
maybe a complex RegEx can detect and remove the trailing ','

still, is easier and more efficient to just "dont put it"
ropu

On Thu, Jul 24, 2008 at 10:58 AM, Gonzalo Aune <go...@gmail.com>
wrote:

> In the examples of the json spec (http://tools.ietf.org/html/rfc4627), he
> never leaves an extra comma after the strings or objects, but in our
> canonicaldb.json we are doing it:
>
>    "john.doe" : [{
>      "id" : "1",
>      "userId" : "john.doe",
>      "title" : "yellow",
>      "body" : "what a color!",           --->HERE!
>    }],
>
>    "schools" : [{
>      "address" : {
>        "unstructuredAddress" : "1 Edu St.",      ----->HERE!
>      },
>      "description" : "High School",
>      "endDate" : "1991-01-01",
>      "field" : "",
>      "name" : "",
>      "salary" : "",
>      "startDate" : "1982-01-01",
>      "subField" : "",
>      "title" : "",
>      "webpage" : ""
>      }],
>
> This is what i meant before... can we only fix this and i'll remove the
> comments with regexp ?
>
> G.-
>
> On Wed, Jul 23, 2008 at 4:03 PM, Chris Chabot <ch...@xs4all.nl> wrote:
>
> > On Jul 23, 2008, at 8:28 PM, Louis Ryan wrote:
> >
> >  We could though technically the extra ',' is allowed by the JSON spec
> and
> >> there's a reasonable chance you'll get JSON with these artifacts coming
> in
> >> from 3rd parties on the RESTful API.  What are the library options on
> the
> >> PHP side to have a more tolerant parser.
> >>
> >
> > We certainly did experiment with this, but the only viable (production
> > ready) solution is a metric ton of native php code, which is 10000x
> slower,
> > slows down the QPM severely (due to the way apache/php loads in the code
> on
> > every request) and crashing on other particularities again, in other
> words
> > not so terribly much :)
> >
> >
> >  For comments we can certainly adopt a convetion to use comments on
> >> newlines
> >> only within Shindig if that helps.
> >>
> >
> > Nah comments are no problem, all we need to do is strip them from the
> > content before parsing it, not optimal but certainly not so bad that i
> would
> > want to try to enforce such rules.
> >
> >        -- Chris
> >
>



-- 
.-. --- .--. ..-
R o p u

Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Gonzalo Aune <go...@gmail.com>.
In the examples of the json spec (http://tools.ietf.org/html/rfc4627), he
never leaves an extra comma after the strings or objects, but in our
canonicaldb.json we are doing it:

    "john.doe" : [{
      "id" : "1",
      "userId" : "john.doe",
      "title" : "yellow",
      "body" : "what a color!",           --->HERE!
    }],

    "schools" : [{
      "address" : {
        "unstructuredAddress" : "1 Edu St.",      ----->HERE!
      },
      "description" : "High School",
      "endDate" : "1991-01-01",
      "field" : "",
      "name" : "",
      "salary" : "",
      "startDate" : "1982-01-01",
      "subField" : "",
      "title" : "",
      "webpage" : ""
      }],

This is what i meant before... can we only fix this and i'll remove the
comments with regexp ?

G.-

On Wed, Jul 23, 2008 at 4:03 PM, Chris Chabot <ch...@xs4all.nl> wrote:

> On Jul 23, 2008, at 8:28 PM, Louis Ryan wrote:
>
>  We could though technically the extra ',' is allowed by the JSON spec and
>> there's a reasonable chance you'll get JSON with these artifacts coming in
>> from 3rd parties on the RESTful API.  What are the library options on the
>> PHP side to have a more tolerant parser.
>>
>
> We certainly did experiment with this, but the only viable (production
> ready) solution is a metric ton of native php code, which is 10000x slower,
> slows down the QPM severely (due to the way apache/php loads in the code on
> every request) and crashing on other particularities again, in other words
> not so terribly much :)
>
>
>  For comments we can certainly adopt a convetion to use comments on
>> newlines
>> only within Shindig if that helps.
>>
>
> Nah comments are no problem, all we need to do is strip them from the
> content before parsing it, not optimal but certainly not so bad that i would
> want to try to enforce such rules.
>
>        -- Chris
>

Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Chris Chabot <ch...@xs4all.nl>.
On Jul 23, 2008, at 8:28 PM, Louis Ryan wrote:

> We could though technically the extra ',' is allowed by the JSON  
> spec and
> there's a reasonable chance you'll get JSON with these artifacts  
> coming in
> from 3rd parties on the RESTful API.  What are the library options  
> on the
> PHP side to have a more tolerant parser.

We certainly did experiment with this, but the only viable (production  
ready) solution is a metric ton of native php code, which is 10000x  
slower, slows down the QPM severely (due to the way apache/php loads  
in the code on every request) and crashing on other particularities  
again, in other words not so terribly much :)


> For comments we can certainly adopt a convetion to use comments on  
> newlines
> only within Shindig if that helps.

Nah comments are no problem, all we need to do is strip them from the  
content before parsing it, not optimal but certainly not so bad that i  
would want to try to enforce such rules.

	-- Chris

Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Louis Ryan <lr...@google.com>.
We could though technically the extra ',' is allowed by the JSON spec and
there's a reasonable chance you'll get JSON with these artifacts coming in
from 3rd parties on the RESTful API.  What are the library options on the
PHP side to have a more tolerant parser.

For comments we can certainly adopt a convetion to use comments on newlines
only within Shindig if that helps.

On Wed, Jul 23, 2008 at 8:32 AM, Ropu <ro...@gmail.com> wrote:

> yeap, thats an issue of the parser.
>
> we had the same problem with config/oauth.json
>
> comments can be removed programatically, but extra ',' no.
>
> can we standardize that with the JAVA guys?
>
> ropu
>
> On Wed, Jul 23, 2008 at 12:01 PM, Gonzalo Aune (JIRA) <ji...@apache.org>
> wrote:
>
> >
> >     [
> >
> https://issues.apache.org/jira/browse/SHINDIG-469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
> ]
> >
> > Gonzalo Aune updated SHINDIG-469:
> > ---------------------------------
> >
> >    Attachment: canonicaldb-fix.patch
> >
> > This is the patch fixing the db.json, it seems like it doesnt accept
> > comments, and there are a couple of errors in some lines with an extra
> ","
> > like:
> >
> > "body" : "what a color!",
> >
> > and
> >
> > "unstructuredAddress" : "1 Edu St.",
> >
> > The patch fix these lines and removes the comments, without these
> changes,
> > PHP json function doesnt decode the string. Is there any possibilities to
> > commit this and add the comments in an README file?
> >
> > G.-
> >
> > > Error parsing canonicaldb.json in PHP
> > > -------------------------------------
> > >
> > >                 Key: SHINDIG-469
> > >                 URL: https://issues.apache.org/jira/browse/SHINDIG-469
> > >             Project: Shindig
> > >          Issue Type: Bug
> > >          Components: RESTful API (Java), RESTful API (PHP)
> > >            Reporter: Gonzalo Aune
> > >         Attachments: canonicaldb-fix.patch
> > >
> > >
> > > I had a couple of errors trying to decode the json db in PHP, it simply
> > dont parse.
> >
> > --
> > This message is automatically generated by JIRA.
> > -
> > You can reply to this email to add a comment to the issue online.
> >
> >
>
>
> --
> .-. --- .--. ..-
> R o p u
>

Re: [jira] Updated: (SHINDIG-469) Error parsing canonicaldb.json in PHP

Posted by Ropu <ro...@gmail.com>.
yeap, thats an issue of the parser.

we had the same problem with config/oauth.json

comments can be removed programatically, but extra ',' no.

can we standardize that with the JAVA guys?

ropu

On Wed, Jul 23, 2008 at 12:01 PM, Gonzalo Aune (JIRA) <ji...@apache.org>
wrote:

>
>     [
> https://issues.apache.org/jira/browse/SHINDIG-469?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel]
>
> Gonzalo Aune updated SHINDIG-469:
> ---------------------------------
>
>    Attachment: canonicaldb-fix.patch
>
> This is the patch fixing the db.json, it seems like it doesnt accept
> comments, and there are a couple of errors in some lines with an extra ","
> like:
>
> "body" : "what a color!",
>
> and
>
> "unstructuredAddress" : "1 Edu St.",
>
> The patch fix these lines and removes the comments, without these changes,
> PHP json function doesnt decode the string. Is there any possibilities to
> commit this and add the comments in an README file?
>
> G.-
>
> > Error parsing canonicaldb.json in PHP
> > -------------------------------------
> >
> >                 Key: SHINDIG-469
> >                 URL: https://issues.apache.org/jira/browse/SHINDIG-469
> >             Project: Shindig
> >          Issue Type: Bug
> >          Components: RESTful API (Java), RESTful API (PHP)
> >            Reporter: Gonzalo Aune
> >         Attachments: canonicaldb-fix.patch
> >
> >
> > I had a couple of errors trying to decode the json db in PHP, it simply
> dont parse.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>


-- 
.-. --- .--. ..-
R o p u