Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] datasource: json format expected

Expand Messages
  • Raphael Bauduin
    ... hem, yes..... Mixing languages..... ... I still get a failure indeed. Does that mean there s no solution to consume that JSON with the datasource
    Message 1 of 12 , May 1, 2008
    View Source
    • 0 Attachment
      On Thu, May 1, 2008 at 7:00 PM, Satyam <satyam@...> wrote:
      > If they contain multiple values, which one is the one you mean to show.
      > There can only be one value returned per field, if there are going to be
      > multiple status objects, which one is the one you care to show? I understand
      > "results" would contain more than one, but the others? Anyway, the DataTable
      > can only show a single value per cell so whatever you can't do that.
      >
      > Besides, the code:
      >
      > function(t){"deadline"}
      >
      > or any other is not invalid but does nothing. It evaluates the string
      > "deadline" and then does nothing with it.
      >
      > function(t){return "deadline"}
      >
      > would, at least, return the string "deadline" which would end up being shown
      > in the Datatable, but that is quite boring and probably not what you mean.


      hem, yes..... Mixing languages.....


      >
      > If, for example, the "status" field had a single item, not an array, you
      > could declare a field like:
      >
      > fields: [...,"status.value",...]
      >
      > and the DataSource will give you the value, it doesn't need a parser to do
      > that.
      >
      > You might even try:
      >
      > "status.0.value"
      >
      > with the data as it is now, which might (though probably not) fetch the
      > value field in the first item in the status array.
      >

      I still get a failure indeed. Does that mean there's no solution to
      consume that JSON with the datasource component?

      Thanks for your help.

      Raph


      >
      > Satyam
      >
      >
      > ----- Original Message -----
      > From: "Raphael Bauduin" <rblists@...>
      > To: <ydn-javascript@yahoogroups.com>
      >
      >
      > Sent: Thursday, May 01, 2008 6:28 PM
      > Subject: Re: [ydn-javascript] datasource: json format expected
      >
      >
      > > On Thu, May 1, 2008 at 6:17 PM, Satyam <satyam@...> wrote:
      > >> The JSON message seems fine to me, though it is quite redundant in that
      > >> you
      > >> have every nested object within an array that only contains that single
      > >> object. Unless any of those arrays is actually meant to contain more
      > >> than
      > >> one item (I guess "resources" would) they are quite unneeded and can
      > >> only
      > >> make it harder on the parser.
      > >
      > > Those arrays are indeed meant to enable multiple values.
      > >
      > >
      > >>
      > >> What is wrong is the responseSchema.fields. The items in the fields
      > >> array
      > >> can be either simple strings giving the property name holding the value
      > >> or
      > >> an object composed of a key and a parser property. You have properties
      > >> status, deadline, description, title which are quite pointless, no
      > >> matter
      > >> what they contain, the best it can be hoped is that the functions will
      > >> be
      > >> ignored.
      > >
      > > Thanks for pointing that out!
      > >
      > > I tried with this version, but still got a failure :(
      > >
      > > myDataSource.responseSchema = {
      > > fields: ["url", "lock_version", "entity_url","details_url", "links_url",
      > > { "key": "status", "parser" : function(status) { "status" }},
      > > {"key":"title", "parser":function(t){"title"}} ,
      > > {"key":"deadline", "parser": function(t){"deadline"}},
      > > {"key": "description", "parser" :function(v){"description"}} ],
      > > resultsList: "resources"
      > > };
      > >
      > > Do all fields in the json have to be present in the fields array?
      > > (trying with some fields not present also give me a failure....)
      > >
      > > Raph
      > >
      > >>
      > >> Satyam
      > >>
      > >>
      > >>
      > >>
      > >> ----- Original Message -----
      > >> From: "Raphael Bauduin" <rblists@...>
      > >> To: <ydn-javascript@yahoogroups.com>
      > >> Sent: Thursday, May 01, 2008 6:00 PM
      > >> Subject: [ydn-javascript] datasource: json format expected
      > >>
      > >>
      > >> > Hi,
      > >> >
      > >> > Is the data source component able to work with this json?
      > >> >
      > >> > { "length" : 3,
      > >> > "resources": [
      > >> > { "url": "http://localhost:3000/instances/5.json",
      > >> > "lock_version": 0,
      > >> > "entity_url": "http://localhost:3000/entities/1.json",
      > >> > "details_url": "http://localhost:3000/entities/1/details.json",
      > >> > "links_url": "http://localhost:3000/instances/5/links.json",
      > >> > "status": [
      > >> > { "url":
      > >> "http://localhost:3000/details/5/values/3.json",
      > >> > "lock_version": 0,
      > >> > "value": "On-hold"}
      > >> > ],
      > >> > "title": [
      > >> > { "url": "http://localhost:3000/details/1/values/6.json",
      > >> > "lock_version": 0, "value": "second test"}
      > >> > ],
      > >> > "deadline": [
      > >> > { "url": "http://localhost:3000/details/4/values/3.json",
      > >> > "lock_version": 0,
      > >> > "value": "2008-05-01 15:35:50"}
      > >> > ],
      > >> > "description": [
      > >> > { "url": "http://localhost:3000/details/2/values/7.json",
      > >> > "lock_version": 0,
      > >> > "value": "another descrpition"}
      > >> > ]
      > >> > }
      > >> > ]
      > >> > }
      > >> >
      > >> > As you can see there are nested objects. I always get a failure, even
      > >> > when I try with parser functions.
      > >> > Here is the latest version of my code, thanks for any hint to solve
      > >> the
      > >> > problem.
      > >> >
      > >> > Raph
      > >> >
      > >> >
      > >> > var oCallback = {
      > >> > success: function(oRequest,oResponse,oPayload) {
      > >> > console.log('success');
      > >> > },
      > >> > failure: function(oRequest,oResponse,oPayload) {
      > >> > console.log('failure');
      > >> > },
      > >> > scope:this
      > >> > }
      > >> >
      > >> > var myDataSource = new
      > >> >
      > >> YAHOO.util.DataSource("http://localhost:3000/entities/1/instances.json?");
      > >> > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
      > >> > myDataSource.responseSchema = {
      > >> > fields: ["url", "lock_version", "entity_url","details_url",
      > >> > "links_url", { "status" : function(status) { "status" }}, {"title":
      > >> > function(t){"title"}} , {"deadline": function(t){"deadline"}},
      > >> > {"description":function(v){"description"}} ],
      > >> > resultsList: "resources"
      > >> > };
      > >> >
      > >> > myDataSource.sendRequest("test=1", oCallback);
      > >> >
      > >> >
      > >> >
      > >> >
      > >> > --
      > >> > Web database: http://www.myowndb.com
      > >> > Free Software Developers Meeting: http://www.fosdem.org
      > >> >
      > >> > ------------------------------------
      > >> >
      > >> > Yahoo! Groups Links
      > >> >
      > >> >
      > >> >
      > >> >
      > >> >
      > >> > --
      > >> > No virus found in this incoming message.
      > >> > Checked by AVG.
      > >> > Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date:
      > >> > 30/04/2008 18:10
      > >> >
      > >> >
      > >>
      > >>
      > >> ------------------------------------
      > >>
      > >> Yahoo! Groups Links
      > >>
      > >>
      > >>
      > >>
      > >
      > >
      > >
      > > --
      >
      >
      > > Web database: http://www.myowndb.com
      > > Free Software Developers Meeting: http://www.fosdem.org
      > >
      > > ------------------------------------
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      > >
      > >
      > > --
      > > No virus found in this incoming message.
      > > Checked by AVG.
      > > Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date:
      > > 30/04/2008 18:10
      > >
      > >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      >



      --
      Web database: http://www.myowndb.com
      Free Software Developers Meeting: http://www.fosdem.org
    • Raphael Bauduin
      ... The logger gives more info: the json could not be parsed: DataSource instance1 JSON data could not be parsed: ({ length : 3, resources: [{ url :
      Message 2 of 12 , May 1, 2008
      View Source
      • 0 Attachment
        On Thu, May 1, 2008 at 7:38 PM, Raphael Bauduin <rblists@...> wrote:
        > On Thu, May 1, 2008 at 7:00 PM, Satyam <satyam@...> wrote:
        > > If they contain multiple values, which one is the one you mean to show.
        > > There can only be one value returned per field, if there are going to be
        > > multiple status objects, which one is the one you care to show? I understand
        > > "results" would contain more than one, but the others? Anyway, the DataTable
        > > can only show a single value per cell so whatever you can't do that.
        > >
        > > Besides, the code:
        > >
        > > function(t){"deadline"}
        > >
        > > or any other is not invalid but does nothing. It evaluates the string
        > > "deadline" and then does nothing with it.
        > >
        > > function(t){return "deadline"}
        > >
        > > would, at least, return the string "deadline" which would end up being shown
        > > in the Datatable, but that is quite boring and probably not what you mean.
        >
        >
        > hem, yes..... Mixing languages.....
        >
        >
        >
        > >
        > > If, for example, the "status" field had a single item, not an array, you
        > > could declare a field like:
        > >
        > > fields: [...,"status.value",...]
        > >
        > > and the DataSource will give you the value, it doesn't need a parser to do
        > > that.
        > >
        > > You might even try:
        > >
        > > "status.0.value"
        > >
        > > with the data as it is now, which might (though probably not) fetch the
        > > value field in the first item in the status array.
        > >
        >
        > I still get a failure indeed. Does that mean there's no solution to
        > consume that JSON with the datasource component?
        >
        > Thanks for your help.
        >
        >
        >
        > Raph


        The logger gives more info: the json could not be parsed:


        DataSource instance1

        JSON data could not be parsed: ({ length : 3, resources: [{"url":
        "http://localhost:3000/instances/5.json", "lock_version": 0,
        "entity_url": "http://localhost:3000/entities/1.json", "details_url":
        "http://localhost:3000/entities/1/details.json", "links_url":
        "http://localhost:3000/instances/5/links.json", "status": [{ "url":
        "http://localhost:3000/details/5/values/3.json", "lock_version": 0,
        "value": "On-hold"}], "title": [{ "url":
        "http://localhost:3000/details/1/values/6.json", "lock_version": 0,
        "value": "second test"}], "deadline": [{ "url":
        "http://localhost:3000/details/4/values/3.json", "lock_version": 0,
        "value": "2008-05-01 15:35:50"}], "description": [{ "url":
        "http://localhost:3000/details/2/values/7.json", "lock_version": 0,
        "value": "another descrpition"}]}, {"url":
        "http://localhost:3000/instances/3.json", "lock_version": 0,
        "entity_url": "http://localhost:3000/entities/1.json", "details_url":
        "http://localhost:3000/entities/1/details.json", "links_url":
        "http://localhost:3000/instances/3/links.json", "status": [{ "url":
        "http://localhost:3000/details/5/values/1.json", "lock_version": 0,
        "value": "Started"}], "title": [{ "url":
        "http://localhost:3000/details/1/values/2.json", "lock_version": 0,
        "value": "test"}], "deadline": [{ "url":
        "http://localhost:3000/details/4/values/1.json", "lock_version": 0,
        "value": "2008-02-15 16:26:19"}], "description": [{ "url":
        "http://localhost:3000/details/2/values/3.json", "lock_version": 0,
        "value": "retest"}]}, {"url":
        "http://localhost:3000/instances/4.json", "lock_version": 0,
        "entity_url": "http://localhost:3000/entities/1.json", "details_url":
        "http://localhost:3000/entities/1/details.json", "links_url":
        "http://localhost:3000/instances/4/links.json", "status": [{ "url":
        "http://localhost:3000/details/5/values/2.json", "lock_version": 0,
        "value": "Started"}], "title": [{ "url":
        "http://localhost:3000/details/1/values/4.json", "lock_version": 0,
        "value": "test"}], "deadline": [{ "url":
        "http://localhost:3000/details/4/values/2.json", "lock_version": 0,
        "value": "2008-05-01 15:35:50"}], "description": [{ "url":
        "http://localhost:3000/details/2/values/5.json", "lock_version": 0,
        "value": "My description"}]}]} )

        I tried with and without the parenthesis (see why at
        http://dhenztm.spaces.live.com/blog/cns!761D77A7A749C21B!724.entry )

        There should be a way to use that json, or am I wrong?

        Raph


        >
        >
        > >
        > > Satyam
        > >
        > >
        > > ----- Original Message -----
        > > From: "Raphael Bauduin" <rblists@...>
        > > To: <ydn-javascript@yahoogroups.com>
        > >
        > >
        > > Sent: Thursday, May 01, 2008 6:28 PM
        > > Subject: Re: [ydn-javascript] datasource: json format expected
        > >
        > >
        > > > On Thu, May 1, 2008 at 6:17 PM, Satyam <satyam@...> wrote:
        > > >> The JSON message seems fine to me, though it is quite redundant in that
        > > >> you
        > > >> have every nested object within an array that only contains that single
        > > >> object. Unless any of those arrays is actually meant to contain more
        > > >> than
        > > >> one item (I guess "resources" would) they are quite unneeded and can
        > > >> only
        > > >> make it harder on the parser.
        > > >
        > > > Those arrays are indeed meant to enable multiple values.
        > > >
        > > >
        > > >>
        > > >> What is wrong is the responseSchema.fields. The items in the fields
        > > >> array
        > > >> can be either simple strings giving the property name holding the value
        > > >> or
        > > >> an object composed of a key and a parser property. You have properties
        > > >> status, deadline, description, title which are quite pointless, no
        > > >> matter
        > > >> what they contain, the best it can be hoped is that the functions will
        > > >> be
        > > >> ignored.
        > > >
        > > > Thanks for pointing that out!
        > > >
        > > > I tried with this version, but still got a failure :(
        > > >
        > > > myDataSource.responseSchema = {
        > > > fields: ["url", "lock_version", "entity_url","details_url", "links_url",
        > > > { "key": "status", "parser" : function(status) { "status" }},
        > > > {"key":"title", "parser":function(t){"title"}} ,
        > > > {"key":"deadline", "parser": function(t){"deadline"}},
        > > > {"key": "description", "parser" :function(v){"description"}} ],
        > > > resultsList: "resources"
        > > > };
        > > >
        > > > Do all fields in the json have to be present in the fields array?
        > > > (trying with some fields not present also give me a failure....)
        > > >
        > > > Raph
        > > >
        > > >>
        > > >> Satyam
        > > >>
        > > >>
        > > >>
        > > >>
        > > >> ----- Original Message -----
        > > >> From: "Raphael Bauduin" <rblists@...>
        > > >> To: <ydn-javascript@yahoogroups.com>
        > > >> Sent: Thursday, May 01, 2008 6:00 PM
        > > >> Subject: [ydn-javascript] datasource: json format expected
        > > >>
        > > >>
        > > >> > Hi,
        > > >> >
        > > >> > Is the data source component able to work with this json?
        > > >> >
        > > >> > { "length" : 3,
        > > >> > "resources": [
        > > >> > { "url": "http://localhost:3000/instances/5.json",
        > > >> > "lock_version": 0,
        > > >> > "entity_url": "http://localhost:3000/entities/1.json",
        > > >> > "details_url": "http://localhost:3000/entities/1/details.json",
        > > >> > "links_url": "http://localhost:3000/instances/5/links.json",
        > > >> > "status": [
        > > >> > { "url":
        > > >> "http://localhost:3000/details/5/values/3.json",
        > > >> > "lock_version": 0,
        > > >> > "value": "On-hold"}
        > > >> > ],
        > > >> > "title": [
        > > >> > { "url": "http://localhost:3000/details/1/values/6.json",
        > > >> > "lock_version": 0, "value": "second test"}
        > > >> > ],
        > > >> > "deadline": [
        > > >> > { "url": "http://localhost:3000/details/4/values/3.json",
        > > >> > "lock_version": 0,
        > > >> > "value": "2008-05-01 15:35:50"}
        > > >> > ],
        > > >> > "description": [
        > > >> > { "url": "http://localhost:3000/details/2/values/7.json",
        > > >> > "lock_version": 0,
        > > >> > "value": "another descrpition"}
        > > >> > ]
        > > >> > }
        > > >> > ]
        > > >> > }
        > > >> >
        > > >> > As you can see there are nested objects. I always get a failure, even
        > > >> > when I try with parser functions.
        > > >> > Here is the latest version of my code, thanks for any hint to solve
        > > >> the
        > > >> > problem.
        > > >> >
        > > >> > Raph
        > > >> >
        > > >> >
        > > >> > var oCallback = {
        > > >> > success: function(oRequest,oResponse,oPayload) {
        > > >> > console.log('success');
        > > >> > },
        > > >> > failure: function(oRequest,oResponse,oPayload) {
        > > >> > console.log('failure');
        > > >> > },
        > > >> > scope:this
        > > >> > }
        > > >> >
        > > >> > var myDataSource = new
        > > >> >
        > > >> YAHOO.util.DataSource("http://localhost:3000/entities/1/instances.json?");
        > > >> > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
        > > >> > myDataSource.responseSchema = {
        > > >> > fields: ["url", "lock_version", "entity_url","details_url",
        > > >> > "links_url", { "status" : function(status) { "status" }}, {"title":
        > > >> > function(t){"title"}} , {"deadline": function(t){"deadline"}},
        > > >> > {"description":function(v){"description"}} ],
        > > >> > resultsList: "resources"
        > > >> > };
        > > >> >
        > > >> > myDataSource.sendRequest("test=1", oCallback);
        > > >> >
        > > >> >
        > > >> >
        > > >> >
        > > >> > --
        > > >> > Web database: http://www.myowndb.com
        > > >> > Free Software Developers Meeting: http://www.fosdem.org
        > > >> >
        > > >> > ------------------------------------
        > > >> >
        > > >> > Yahoo! Groups Links
        > > >> >
        > > >> >
        > > >> >
        > > >> >
        > > >> >
        > > >> > --
        > > >> > No virus found in this incoming message.
        > > >> > Checked by AVG.
        > > >> > Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date:
        > > >> > 30/04/2008 18:10
        > > >> >
        > > >> >
        > > >>
        > > >>
        > > >> ------------------------------------
        > > >>
        > > >> Yahoo! Groups Links
        > > >>
        > > >>
        > > >>
        > > >>
        > > >
        > > >
        > > >
        > > > --
        > >
        > >
        > > > Web database: http://www.myowndb.com
        > > > Free Software Developers Meeting: http://www.fosdem.org
        > > >
        > > > ------------------------------------
        > > >
        > > > Yahoo! Groups Links
        > > >
        > > >
        > > >
        > > >
        > > >
        > > > --
        > > > No virus found in this incoming message.
        > > > Checked by AVG.
        > > > Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date:
        > > > 30/04/2008 18:10
        > > >
        > > >
        > >
        > >
        > > ------------------------------------
        > >
        > > Yahoo! Groups Links
        > >
        > >
        > >
        > >
        >
        >
        >
        > --
        >
        >
        > Web database: http://www.myowndb.com
        > Free Software Developers Meeting: http://www.fosdem.org
        >



        --
        Web database: http://www.myowndb.com
        Free Software Developers Meeting: http://www.fosdem.org
      • Raphael Bauduin
        ... I got it working, though the JSON returned is different. Looking at datasource-beta-debug at line 1566, there s a test on resultsList, which is used if
        Message 3 of 12 , May 1, 2008
        View Source
        • 0 Attachment
          >
          > There should be a way to use that json, or am I wrong?
          >

          I got it working, though the JSON returned is different.
          Looking at datasource-beta-debug at line 1566, there's a test on
          resultsList, which is used if present. The problem must be in
          walkPath:

          1566 if (schema.resultsList) {
          1567 path = buildPath(schema.resultsList);
          1568 if (path) {
          1569 resultsList = walkPath(path, oFullResponse);
          1570 if (resultsList === undefined) {
          1571 bError = true;
          1572 }
          1573 } else {
          1574 bError = true;
          1575 }
          1576 }


          The default behaviour is to consider the received data as an array,
          and it occurs when no resultsList is passed. So when returning all
          data in an array and using this code it works fine:

          myDataSource.responseSchema = {
          fields: ["url", "lock_version", "entity_url","details_url",
          "links_url", { "key": "status", "parser" : function(status) { "status"
          }}, {key:"title", parser: function(t){return "title"}} , {key:
          "deadline", parser: function(t){return "deadline"}},
          {key:"description", parser:function(v){return "description"}} ]
          };


          The downside is that there's no meta information available :(
          I don't have the opportunity to dig deeper right now, but will do
          later. So if you have any hints, don't hesitate to let me know ;-)

          Raph





          --
          Web database: http://www.myowndb.com
          Free Software Developers Meeting: http://www.fosdem.org
        • y_lsmith
          Raph, DataSource is capable of extracting values from nested structures . However, it looks like
          Message 4 of 12 , May 1, 2008
          View Source
          • 0 Attachment
            Raph,

            DataSource is capable of extracting values from nested structures.  However, it looks like you want to capture the collection of values for your columns 'status', 'title', 'deadline', and 'description'.  Keep in mind that DataTable doesn't support tree like row structures, but you could use a custom formatter to turn the array data into a single cell value.  I threw together this example page  to show how to do it.

            Hope this helps,
            Luke

            --- In ydn-javascript@yahoogroups.com, "Raphael Bauduin" <rblists@...> wrote:
            >
            > Hi,
            >
            > Is the data source component able to work with this json?
            >
            > { "length" : 3,
            > "resources": [
            > { "url": "http://localhost:3000/instances/5.json",
            > "lock_version": 0,
            > "entity_url": "http://localhost:3000/entities/1.json",
            > "details_url": "http://localhost:3000/entities/1/details.json",
            > "links_url": "http://localhost:3000/instances/5/links.json",
            > "status": [
            > { "url": "http://localhost:3000/details/5/values/3.json",
            > "lock_version": 0,
            > "value": "On-hold"}
            > ],
            > "title": [
            > { "url": "http://localhost:3000/details/1/values/6.json",
            > "lock_version": 0, "value": "second test"}
            > ],
            > "deadline": [
            > { "url": "http://localhost:3000/details/4/values/3.json",
            > "lock_version": 0,
            > "value": "2008-05-01 15:35:50"}
            > ],
            > "description": [
            > { "url": "http://localhost:3000/details/2/values/7.json",
            > "lock_version": 0,
            > "value": "another descrpition"}
            > ]
            > }
            > ]
            > }
            >
            > As you can see there are nested objects. I always get a failure, even
            > when I try with parser functions.
            > Here is the latest version of my code, thanks for any hint to solve the problem.
            >
            > Raph
            >
            >
            > var oCallback = {
            > success: function(oRequest,oResponse,oPayload) {
            > console.log('success');
            > },
            > failure: function(oRequest,oResponse,oPayload) {
            > console.log('failure');
            > },
            > scope:this
            > }
            >
            > var myDataSource = new
            > YAHOO.util.DataSource("http://localhost:3000/entities/1/instances.json?");
            > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
            > myDataSource.responseSchema = {
            > fields: ["url", "lock_version", "entity_url","details_url",
            > "links_url", { "status" : function(status) { "status" }}, {"title":
            > function(t){"title"}} , {"deadline": function(t){"deadline"}},
            > {"description":function(v){"description"}} ],
            > resultsList: "resources"
            > };
            >
            > myDataSource.sendRequest("test=1", oCallback);
            >
            >
            >
            >
            > --
            > Web database: http://www.myowndb.com
            > Free Software Developers Meeting: http://www.fosdem.org
            >
          • Satyam
            Sorry about the missinformation I provided. Thanks for the correction. Satyam ... From: y_lsmith To: ydn-javascript@yahoogroups.com Sent: Thursday, May 01,
            Message 5 of 12 , May 2, 2008
            View Source
            • 0 Attachment
              Sorry about the missinformation I provided. Thanks for the correction.
               
              Satyam
               
              ----- Original Message -----
              From: y_lsmith
              Sent: Thursday, May 01, 2008 9:35 PM
              Subject: [ydn-javascript] Re: datasource: json format expected

              Raph,

              DataSource is capable of extracting values from nested structures.  However, it looks like you want to capture the collection of values for your columns 'status', 'title', 'deadline', and 'description'.  Keep in mind that DataTable doesn't support tree like row structures, but you could use a custom formatter to turn the array data into a single cell value.  I threw together this example page  to show how to do it.

              Hope this helps,
              Luke

              --- In ydn-javascript@yahoogroups.com, "Raphael Bauduin" <rblists@...> wrote:
              >
              > Hi,
              >
              > Is the data source component able to work with this json?
              >
              > { "length" : 3,
              > "resources": [
              > { "url": "http://localhost:3000/instances/5.json",
              > "lock_version": 0,
              > "entity_url": "htp://localhost:3000/entities/1.json",
              > "details_url": "http://localhost:3000/entities/1/details.json",
              > "links_url": "http://localhost:3000/instances/5/links.json",
              > "status": [
              > { "url": "http://localhost:3000/details/5/values/3.json",
              > "lock_version": 0,
              > "value": "On-hold"}
              > ],
              > "title": [
              > { "url": "http://localhost:3000/details/1/values/6.json",
              > "lock_version": 0, "value": "second test"}
              > ],
              > "deadline": [
              > { "url": "http://localhost:3000/details/4/values/3.json",
              > "lock_version": 0,
              > "value": "2008-05-01 15:35:50"}
              > ],
              > "description": [
              > { "url": "http://localhost:3000/details/2/values/7.json",
              > "lock_version": 0,
              > "value": "anoh er descrpition"}
              > ]
              > }
              > ]
              > }
              >
              > As you can see there are nested objects. I always get a failure, even
              > when I try with parser functions.
              > Here is the latest version of my code, thanks for any hint to solve the problem.
              >
              > Raph
              >
              >
              > var oCallback = {
              > success: function(oRequest,oResponse,oPayload) {
              > console.log('success');
              > },
              > failure: function(oRequest,oResponse,oPayload) {
              > console.log('failure');
              > },
              > scope:this
              > }
              >
              > var myDataSource = new
              > YAHOO.util.DataSource("http://localhost:3000/entities/1/instances.json?");
              > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
              > myDataSource.responseSchema = {
              > fields: ["url", "lock_version", "entity_url","details_url",
              > "links_url", { "status" : function(status) { "status" }}, {"title":
              > function(t){"title"}} , {"deadlin": function(t){"deadline"}},
              > {"description":function(v){"description"}} ],
              > resultsList: "resources"
              > };
              >
              > myDataSource.sendRequest("test=1", oCallback);
              >
              >
              >
              >
              > --
              > Web database: http://www.myowndb.com
              > Free Software Developers Meeting: http://www.fosdem.org
              >


              No virus found in this incoming message.
              Checked by AVG.
              Version: 7.5.524 / Virus Database: 269.23.7/1408 - Release Date: 30/04/2008 18:10
            • Raphael Bauduin
              ... Hi Luke, thanks for taking a look at this! I will indeed look at a custom formatter once I can use the json, but I m still not there :( I ve looked closely
              Message 6 of 12 , May 2, 2008
              View Source
              • 0 Attachment
                On Thu, May 1, 2008 at 9:35 PM, y_lsmith <lsmith@...> wrote:
                >
                > Raph,
                >
                > DataSource is capable of extracting values from nested structures. However,
                > it looks like you want to capture the collection of values for your columns
                > 'status', 'title', 'deadline', and 'description'. Keep in mind that
                > DataTable doesn't support tree like row structures, but you could use a
                > custom formatter to turn the array data into a single cell value. I threw
                > together this example page to show how to do it.

                Hi Luke,

                thanks for taking a look at this! I will indeed look at a custom
                formatter once I can use the json, but I'm still not there :(
                I've looked closely at your example, and simplified my code a lot. I'm
                now trying with this code, but still without success:

                myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
                myDataSource.responseSchema = {
                fields: ["url" ],
                resultsList: "resources"
                };

                I put a page with code consuming the json at http://www.raphinou.com/test.html
                There you can just copy and paste the javascript code displayed on the
                page in the firebug console, and you should get a failure.

                I hope you have the opportunity to take a look because I really don't
                see what I'm doing wrong here.

                Thanks

                Raph



                >
                > Hope this helps,
                > Luke
                >
                >
                >
                > --- In ydn-javascript@yahoogroups.com, "Raphael Bauduin" <rblists@...>
                > wrote:
                > >
                > > Hi,
                > >
                > > Is the data source component able to work with this json?
                > >
                > > { "length" : 3,
                > > "resources": [
                > > { "url": "http://localhost:3000/instances/5.json",
                > > "lock_version": 0,
                > > "entity_url": "http://localhost:3000/entities/1.json",
                > > "details_url": "http://localhost:3000/entities/1/details.json",
                > > "links_url": "http://localhost:3000/instances/5/links.json",
                > > "status": [
                > > { "url": "http://localhost:3000/details/5/values/3.json",
                > > "lock_version": 0,
                > > "value": "On-hold"}
                > > ],
                > > "title": [
                > > { "url": "http://localhost:3000/details/1/values/6.json",
                > > "lock_version": 0, "value": "second test"}
                > > ],
                > > "deadline": [
                > > { "url": "http://localhost:3000/details/4/values/3.json",
                > > "lock_version": 0,
                > > "value": "2008-05-01 15:35:50"}
                > > ],
                > > "description": [
                > > { "url": "http://localhost:3000/details/2/values/7.json",
                > > "lock_version": 0,
                > > "value": "another descrpition"}
                > > ]
                > > }
                > > ]
                > > }
                > >
                > > As you can see there are nested objects. I always get a failure, even
                > > when I try with parser functions.
                > > Here is the latest version of my code, thanks for any hint to solve the
                > problem.
                > >
                > > Raph
                > >
                > >
                > > var oCallback = {
                > > success: function(oRequest,oResponse,oPayload) {
                > > console.log('success');
                > > },
                > > failure: function(oRequest,oResponse,oPayload) {
                > > console.log('failure');
                > > },
                > > scope:this
                > > }
                > >
                > > var myDataSource = new
                > > YAHOO.util.DataSource("http://localhost:3000/entities/1/instances.json?");
                > > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
                > > myDataSource.responseSchema = {
                > > fields: ["url", "lock_version", "entity_url","details_url",
                > > "links_url", { "status" : function(status) { "status" }}, {"title":
                > > function(t){"title"}} , {"deadline": function(t){"deadline"}},
                > > {"description":function(v){"description"}} ],
                > > resultsList: "resources"
                > > };
                > >
                > > myDataSource.sendRequest("test=1", oCallback);
                > >
                > >
                > >
                > >
                > > --
                > > Web database: http://www.myowndb.com
                > > Free Software Developers Meeting: http://www.fosdem.org
                > >
                >



                --
                Web database: http://www.myowndb.com
                Free Software Developers Meeting: http://www.fosdem.org
              • Satyam
                If you are including the JSON component, it will fail, if not, it will work. The DataSource comes with a JSON decoded which is somewhat more tolerant than the
                Message 7 of 12 , May 2, 2008
                View Source
                • 0 Attachment
                  If you are including the JSON component, it will fail, if not, it will work.
                  The DataSource comes with a JSON decoded which is somewhat more tolerant
                  than the standard. It will accept unquoted identifiers. The JSON component
                  is stricter and won't take your JSON message because the first two
                  identifiers, length and resources are not within quotes. So, either make
                  sure to put quotes around all identifiers or don't load the JSON component
                  and let the DataSource deal with it. I recomend the first one since,
                  eventually, the DataSource will catch up with the standard and will also
                  fail.

                  Satyam

                  ----- Original Message -----
                  From: "Raphael Bauduin" <rblists@...>
                  To: <ydn-javascript@yahoogroups.com>
                  Sent: Friday, May 02, 2008 11:55 AM
                  Subject: Re: [ydn-javascript] Re: datasource: json format expected


                  > On Thu, May 1, 2008 at 9:35 PM, y_lsmith <lsmith@...> wrote:
                  >>
                  >> Raph,
                  >>
                  >> DataSource is capable of extracting values from nested structures.
                  >> However,
                  >> it looks like you want to capture the collection of values for your
                  >> columns
                  >> 'status', 'title', 'deadline', and 'description'. Keep in mind that
                  >> DataTable doesn't support tree like row structures, but you could use a
                  >> custom formatter to turn the array data into a single cell value. I
                  >> threw
                  >> together this example page to show how to do it.
                  >
                  > Hi Luke,
                  >
                  > thanks for taking a look at this! I will indeed look at a custom
                  > formatter once I can use the json, but I'm still not there :(
                  > I've looked closely at your example, and simplified my code a lot. I'm
                  > now trying with this code, but still without success:
                  >
                  > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
                  > myDataSource.responseSchema = {
                  > fields: ["url" ],
                  > resultsList: "resources"
                  > };
                  >
                  > I put a page with code consuming the json at
                  > http://www.raphinou.com/test.html
                  > There you can just copy and paste the javascript code displayed on the
                  > page in the firebug console, and you should get a failure.
                  >
                  > I hope you have the opportunity to take a look because I really don't
                  > see what I'm doing wrong here.
                  >
                  > Thanks
                  >
                  > Raph
                  >
                  >
                  >
                  >>
                  >> Hope this helps,
                  >> Luke
                  >>
                  >>
                  >>
                  >> --- In ydn-javascript@yahoogroups.com, "Raphael Bauduin" <rblists@...>
                  >> wrote:
                  >> >
                  >> > Hi,
                  >> >
                  >> > Is the data source component able to work with this json?
                  >> >
                  >> > { "length" : 3,
                  >> > "resources": [
                  >> > { "url": "http://localhost:3000/instances/5.json",
                  >> > "lock_version": 0,
                  >> > "entity_url": "http://localhost:3000/entities/1.json",
                  >> > "details_url": "http://localhost:3000/entities/1/details.json",
                  >> > "links_url": "http://localhost:3000/instances/5/links.json",
                  >> > "status": [
                  >> > { "url": "http://localhost:3000/details/5/values/3.json",
                  >> > "lock_version": 0,
                  >> > "value": "On-hold"}
                  >> > ],
                  >> > "title": [
                  >> > { "url": "http://localhost:3000/details/1/values/6.json",
                  >> > "lock_version": 0, "value": "second test"}
                  >> > ],
                  >> > "deadline": [
                  >> > { "url": "http://localhost:3000/details/4/values/3.json",
                  >> > "lock_version": 0,
                  >> > "value": "2008-05-01 15:35:50"}
                  >> > ],
                  >> > "description": [
                  >> > { "url": "http://localhost:3000/details/2/values/7.json",
                  >> > "lock_version": 0,
                  >> > "value": "another descrpition"}
                  >> > ]
                  >> > }
                  >> > ]
                  >> > }
                  >> >
                  >> > As you can see there are nested objects. I always get a failure, even
                  >> > when I try with parser functions.
                  >> > Here is the latest version of my code, thanks for any hint to solve the
                  >> problem.
                  >> >
                  >> > Raph
                  >> >
                  >> >
                  >> > var oCallback = {
                  >> > success: function(oRequest,oResponse,oPayload) {
                  >> > console.log('success');
                  >> > },
                  >> > failure: function(oRequest,oResponse,oPayload) {
                  >> > console.log('failure');
                  >> > },
                  >> > scope:this
                  >> > }
                  >> >
                  >> > var myDataSource = new
                  >> > YAHOO.util.DataSource("http://localhost:3000/entities/1/instances.json?");
                  >> > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
                  >> > myDataSource.responseSchema = {
                  >> > fields: ["url", "lock_version", "entity_url","details_url",
                  >> > "links_url", { "status" : function(status) { "status" }}, {"title":
                  >> > function(t){"title"}} , {"deadline": function(t){"deadline"}},
                  >> > {"description":function(v){"description"}} ],
                  >> > resultsList: "resources"
                  >> > };
                  >> >
                  >> > myDataSource.sendRequest("test=1", oCallback);
                  >> >
                  >> >
                  >> >
                  >> >
                  >> > --
                  >> > Web database: http://www.myowndb.com
                  >> > Free Software Developers Meeting: http://www.fosdem.org
                  >> >
                  >>
                  >
                  >
                  >
                  > --
                  > Web database: http://www.myowndb.com
                  > Free Software Developers Meeting: http://www.fosdem.org
                  >
                  > ------------------------------------
                  >
                  > Yahoo! Groups Links
                  >
                  >
                  >
                  >
                  >
                  > --
                  > No virus found in this incoming message.
                  > Checked by AVG.
                  > Version: 7.5.524 / Virus Database: 269.23.7/1410 - Release Date:
                  > 01/05/2008 17:30
                  >
                  >
                • Raphael Bauduin
                  ... That s working indeed! Thanks Satyam and Luke for taking the time to help me!! Raph ... -- Web database: http://www.myowndb.com Free Software Developers
                  Message 8 of 12 , May 2, 2008
                  View Source
                  • 0 Attachment
                    On Fri, May 2, 2008 at 12:29 PM, Satyam <satyam@...> wrote:
                    > If you are including the JSON component, it will fail, if not, it will work.
                    > The DataSource comes with a JSON decoded which is somewhat more tolerant
                    > than the standard. It will accept unquoted identifiers. The JSON component
                    > is stricter and won't take your JSON message because the first two
                    > identifiers, length and resources are not within quotes. So, either make
                    > sure to put quotes around all identifiers or don't load the JSON component
                    > and let the DataSource deal with it. I recomend the first one since,
                    > eventually, the DataSource will catch up with the standard and will also
                    > fail.
                    >

                    That's working indeed!

                    Thanks Satyam and Luke for taking the time to help me!!

                    Raph



                    >
                    > Satyam
                    >
                    > ----- Original Message -----
                    > From: "Raphael Bauduin" <rblists@...>
                    >
                    > To: <ydn-javascript@yahoogroups.com>
                    >
                    >
                    > Sent: Friday, May 02, 2008 11:55 AM
                    > Subject: Re: [ydn-javascript] Re: datasource: json format expected
                    >
                    >
                    > > On Thu, May 1, 2008 at 9:35 PM, y_lsmith <lsmith@...> wrote:
                    > >>
                    > >> Raph,
                    > >>
                    > >> DataSource is capable of extracting values from nested structures.
                    > >> However,
                    > >> it looks like you want to capture the collection of values for your
                    > >> columns
                    > >> 'status', 'title', 'deadline', and 'description'. Keep in mind that
                    > >> DataTable doesn't support tree like row structures, but you could use a
                    > >> custom formatter to turn the array data into a single cell value. I
                    > >> threw
                    > >> together this example page to show how to do it.
                    > >
                    > > Hi Luke,
                    > >
                    > > thanks for taking a look at this! I will indeed look at a custom
                    > > formatter once I can use the json, but I'm still not there :(
                    > > I've looked closely at your example, and simplified my code a lot. I'm
                    > > now trying with this code, but still without success:
                    > >
                    > > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
                    > > myDataSource.responseSchema = {
                    > > fields: ["url" ],
                    > > resultsList: "resources"
                    > > };
                    > >
                    > > I put a page with code consuming the json at
                    > > http://www.raphinou.com/test.html
                    > > There you can just copy and paste the javascript code displayed on the
                    > > page in the firebug console, and you should get a failure.
                    > >
                    > > I hope you have the opportunity to take a look because I really don't
                    > > see what I'm doing wrong here.
                    > >
                    > > Thanks
                    > >
                    > > Raph
                    > >
                    > >
                    > >
                    > >>
                    > >> Hope this helps,
                    > >> Luke
                    > >>
                    > >>
                    > >>
                    > >> --- In ydn-javascript@yahoogroups.com, "Raphael Bauduin" <rblists@...>
                    > >> wrote:
                    > >> >
                    > >> > Hi,
                    > >> >
                    > >> > Is the data source component able to work with this json?
                    > >> >
                    > >> > { "length" : 3,
                    > >> > "resources": [
                    > >> > { "url": "http://localhost:3000/instances/5.json",
                    > >> > "lock_version": 0,
                    > >> > "entity_url": "http://localhost:3000/entities/1.json",
                    > >> > "details_url": "http://localhost:3000/entities/1/details.json",
                    > >> > "links_url": "http://localhost:3000/instances/5/links.json",
                    > >> > "status": [
                    > >> > { "url": "http://localhost:3000/details/5/values/3.json",
                    > >> > "lock_version": 0,
                    > >> > "value": "On-hold"}
                    > >> > ],
                    > >> > "title": [
                    > >> > { "url": "http://localhost:3000/details/1/values/6.json",
                    > >> > "lock_version": 0, "value": "second test"}
                    > >> > ],
                    > >> > "deadline": [
                    > >> > { "url": "http://localhost:3000/details/4/values/3.json",
                    > >> > "lock_version": 0,
                    > >> > "value": "2008-05-01 15:35:50"}
                    > >> > ],
                    > >> > "description": [
                    > >> > { "url": "http://localhost:3000/details/2/values/7.json",
                    > >> > "lock_version": 0,
                    > >> > "value": "another descrpition"}
                    > >> > ]
                    > >> > }
                    > >> > ]
                    > >> > }
                    > >> >
                    > >> > As you can see there are nested objects. I always get a failure, even
                    > >> > when I try with parser functions.
                    > >> > Here is the latest version of my code, thanks for any hint to solve the
                    > >> problem.
                    > >> >
                    > >> > Raph
                    > >> >
                    > >> >
                    > >> > var oCallback = {
                    > >> > success: function(oRequest,oResponse,oPayload) {
                    > >> > console.log('success');
                    > >> > },
                    > >> > failure: function(oRequest,oResponse,oPayload) {
                    > >> > console.log('failure');
                    > >> > },
                    > >> > scope:this
                    > >> > }
                    > >> >
                    > >> > var myDataSource = new
                    > >> > YAHOO.util.DataSource("http://localhost:3000/entities/1/instances.json?");
                    > >> > myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
                    > >> > myDataSource.responseSchema = {
                    > >> > fields: ["url", "lock_version", "entity_url","details_url",
                    > >> > "links_url", { "status" : function(status) { "status" }}, {"title":
                    > >> > function(t){"title"}} , {"deadline": function(t){"deadline"}},
                    > >> > {"description":function(v){"description"}} ],
                    > >> > resultsList: "resources"
                    > >> > };
                    > >> >
                    > >> > myDataSource.sendRequest("test=1", oCallback);
                    > >> >
                    > >> >
                    > >> >
                    > >> >
                    > >> > --
                    > >> > Web database: http://www.myowndb.com
                    > >> > Free Software Developers Meeting: http://www.fosdem.org
                    > >> >
                    > >>
                    > >
                    > >
                    > >
                    > > --
                    >
                    > > Web database: http://www.myowndb.com
                    > > Free Software Developers Meeting: http://www.fosdem.org
                    > >
                    > > ------------------------------------
                    > >
                    > > Yahoo! Groups Links
                    > >
                    > >
                    > >
                    > >
                    > >
                    > > --
                    >
                    > > No virus found in this incoming message.
                    > > Checked by AVG.
                    > > Version: 7.5.524 / Virus Database: 269.23.7/1410 - Release Date:
                    > > 01/05/2008 17:30
                    >
                    > >
                    > >
                    >
                    >
                    > ------------------------------------
                    >
                    > Yahoo! Groups Links
                    >
                    >
                    >
                    >
                    >
                    >



                    --
                    Web database: http://www.myowndb.com
                    Free Software Developers Meeting: http://www.fosdem.org
                  Your message has been successfully submitted and would be delivered to recipients shortly.