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

"Invalid Label" error

Expand Messages
  • Ryan Huff
    Hello. Ordinarily I wouldn t ask others to debug a problem I m having with MY code, but I m stuck. Being a total newbie to JSON, I m afraid I don t have enough
    Message 1 of 2 , Apr 2 6:42 PM
    View Source
    • 0 Attachment
      Hello. Ordinarily I wouldn't ask others to debug a problem I'm having
      with MY code, but I'm stuck. Being a total newbie to JSON, I'm afraid
      I don't have enough experience to understand what this error means.

      When I eval the json string, FireFox gives me an error that simply
      says "Invalid label" (and points to the ':' between "mapid" and "1").

      here's my code:

      var json =
      eval('{"mapid":"1","us_metric":"us","out_and_back":"0","rspoints":[{"key":"-117.8695678711_33.7391868646","lat":"33.7391868646","long":"-117.8695678711","order":"0","type":"point","turn":"null","street":"null","elevation":"99.3","distance":"0.00","previous":"","next":"-117.9176330566_33.6271985166"},{"key":"-117.9176330566_33.6271985166","lat":"33.6271985166","long":"-117.9176330566","order":"1","type":"point","turn":"null","street":"null","elevation":"94.3","distance":"0.00","previous":"-117.8695678711_33.7391868646","next":"-117.6635742187_33.6100445737"},{"key":"-117.6635742187_33.6100445737","lat":"33.6100445737","long":"-117.6635742187","order":"2","type":"point","turn":"null","street":"null","elevation":"482.9","distance":"0.00","previous":"-117.9176330566_33.6271985166","next":""}],"center_lat":"33.674615719150","center_long":"-117.790603637650","zoom":7,"first_point_key":"33.7391868646_-117.8695678711","last_point_key":"-117.6635742187_33.6100445737"}');

      A more legible version of this string is:
      {
      "mapid":"1",
      "us_metric":"us",
      "out_and_back":"0",
      "rspoints":[
      {
      "key":"-117.8695678711_33.7391868646",
      "lat":"33.7391868646",
      "long":"-117.8695678711",
      "order":"0",
      "type":"point",
      "turn":"null",
      "street":"null",
      "elevation":"99.3",
      "distance":"0.00",
      "previous":"",
      "next":"-117.9176330566_33.6271985166"
      },
      {
      "key":"-117.9176330566_33.6271985166",
      "lat":"33.6271985166",
      "long":"-117.9176330566",
      "order":"1",
      "type":"point",
      "turn":"null",
      "street":"null",
      "elevation":"94.3",
      "distance":"0.00",
      "previous":"-117.8695678711_33.7391868646",
      "next":"-117.6635742187_33.6100445737"
      },
      {
      "key":"-117.6635742187_33.6100445737",
      "lat":"33.6100445737",
      "long":"-117.6635742187",
      "order":"2",
      "type":"point",
      "turn":"null",
      "street":"null",
      "elevation":"482.9",
      "distance":"0.00",
      "previous":"-117.9176330566_33.6271985166",
      "next":""
      }
      ],

      "center_lat":"33.674615719150",
      "center_long":"-117.790603637650",
      "zoom":7,
      "first_point_key":"33.7391868646_-117.8695678711",
      "last_point_key":"-117.6635742187_33.6100445737"
      }

      Thanks for your help!
    • Pavan Kumar Keely
      Hi Ryan, When you eval a json string, enclose that string in between ( and ) . So, to correct your example, the json part of the eval statement would be:
      Message 2 of 2 , Apr 2 8:06 PM
      View Source
      • 0 Attachment
        Hi Ryan,

        When you eval a json string, enclose that string in between "(" and ")". So, to correct your example, the json part of the eval statement would be:

        var json =
        eval('('+'{"mapid":"1","us_metric":"us","out_and_back":"0","rspoints":[{"key":"-117.8695678711_33.7391868646","lat":"33.7391868646","long":"-117.8695678711","order":"0","type":"point","turn":"null","street":"null","elevation":"99.3","distance":"0.00","previous":"","next":"-117.9176330566_33.6271985166"},{"key":"-117.9176330566_33.6271985166","lat":"33.6271985166","long":"-117.9176330566","order":"1","type":"point","turn":"null","street":"null","elevation":"94.3","distance":"0.00","previous":"-117.8695678711_33.7391868646","next":"-117.6635742187_33.6100445737"},{"key":"-117.6635742187_33.6100445737","lat":"33.6100445737","long":"-117.6635742187","order":"2","type":"point","turn":"null","street":"null","elevation":"482.9","distance":"0.00","previous":"-117.9176330566_33.6271985166","next":""}],"center_lat":"33.674615719150","center_long":"-117.790603637650","zoom":7,"first_point_key":"33.7391868646_-117.8695678711","last_point_key":"-117.6635742187_33.6100445737"}' + ')' );

        I separated "(" and ")" because I think you may be getting this json string dynamically form a server response.

        Please feel free to contact again if it doesn;t work.

        Pavan Keely


        Ryan Huff <routeslip@...> wrote:
        Hello. Ordinarily I wouldn't ask others to debug a problem I'm having
        with MY code, but I'm stuck. Being a total newbie to JSON, I'm afraid
        I don't have enough experience to understand what this error means.

        When I eval the json string, FireFox gives me an error that simply
        says "Invalid label" (and points to the ':' between "mapid" and "1").

        here's my code:

        var json =
        eval('{"mapid":"1","us_metric":"us","out_and_back":"0","rspoints":[{"key":"-117.8695678711_33.7391868646","lat":"33.7391868646","long":"-117.8695678711","order":"0","type":"point","turn":"null","street":"null","elevation":"99.3","distance":"0.00","previous":"","next":"-117.9176330566_33.6271985166"},{"key":"-117.9176330566_33.6271985166","lat":"33.6271985166","long":"-117.9176330566","order":"1","type":"point","turn":"null","street":"null","elevation":"94.3","distance":"0.00","previous":"-117.8695678711_33.7391868646","next":"-117.6635742187_33.6100445737"},{"key":"-117.6635742187_33.6100445737","lat":"33.6100445737","long":"-117.6635742187","order":"2","type":"point","turn":"null","street":"null","elevation":"482.9","distance":"0.00","previous":"-117.9176330566_33.6271985166","next":""}],"center_lat":"33.674615719150","center_long":"-117.790603637650","zoom":7,"first_point_key":"33.7391868646_-117.8695678711","last_point_key":"-117.6635742187_33.6100445737"}');
        A more legible version of this string is:
        {
        "mapid":"1",
        "us_metric":"us",
        "out_and_back":"0",
        "rspoints":[
        {
        "key":"-117.8695678711_33.7391868646",
        "lat":"33.7391868646",
        "long":"-117.8695678711",
        "order":"0",
        "type":"point",
        "turn":"null",
        "street":"null",
        "elevation":"99.3",
        "distance":"0.00",
        "previous":"",
        "next":"-117.9176330566_33.6271985166"
        },
        {
        "key":"-117.9176330566_33.6271985166",
        "lat":"33.6271985166",
        "long":"-117.9176330566",
        "order":"1",
        "type":"point",
        "turn":"null",
        "street":"null",
        "elevation":"94.3",
        "distance":"0.00",
        "previous":"-117.8695678711_33.7391868646",
        "next":"-117.6635742187_33.6100445737"
        },
        {
        "key":"-117.6635742187_33.6100445737",
        "lat":"33.6100445737",
        "long":"-117.6635742187",
        "order":"2",
        "type":"point",
        "turn":"null",
        "street":"null",
        "elevation":"482.9",
        "distance":"0.00",
        "previous":"-117.9176330566_33.6271985166",
        "next":""
        }
        ],

        "center_lat":"33.674615719150",
        "center_long":"-117.790603637650",
        "zoom":7,
        "first_point_key":"33.7391868646_-117.8695678711",
        "last_point_key":"-117.6635742187_33.6100445737"
        }

        Thanks for your help!





        ---------------------------------
        YAHOO! GROUPS LINKS


        Visit your group "json" on the web.

        To unsubscribe from this group, send an email to:
        json-unsubscribe@yahoogroups.com

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


        ---------------------------------





        ---------------------------------
        Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.