JSON parse failure - please help

Discussion in 'Javascript' started by ShutterMan, Jul 26, 2008.

  1. ShutterMan

    ShutterMan Guest

    I have a JSON object as below (data is from SQL Server Northwind
    Database). But doing an eval on it returns an error "unterminated
    string constant" or such. Can someone help me pinpoint the element
    that is causing the grief? Sorry to post the entire object, but Im
    hoping someone has a parse utility that will help find whats wrong.

    { "TABLE":[{ "ROW":[ { "COL":[ {"DATA":"EmployeeID"},
    {"DATA":"LastName"},{"DATA":"FirstName"},{"DATA":"Title"},
    {"DATA":"TitleOfCourtesy"},{"DATA":"BirthDate"},{"DATA":"HireDate"},
    {"DATA":"Address"},{"DATA":"City"},{"DATA":"Region"},
    {"DATA":"PostalCode"},{"DATA":"Country"},{"DATA":"HomePhone"},
    {"DATA":"Extension"},{"DATA":"Photo"},{"DATA":"Notes"},
    {"DATA":"ReportsTo"},{"DATA":"PhotoPath"}]}, { "COL":[ {"DATA":"1"},
    {"DATA":"Davolio"},{"DATA":"Nancy"},{"DATA":"Sales Representative"},
    {"DATA":"Ms."},{"DATA":"12/8/1948 12:00:00 AM"},{"DATA":"5/1/1992
    12:00:00 AM"},{"DATA":"507 - 20th Ave. E.
    Apt. 2A"},{"DATA":"Seattle"},{"DATA":"WA"},{"DATA":"98122"},
    {"DATA":"USA"},{"DATA":"(206) 555-9857"},{"DATA":"5467"},
    {"DATA":"System.Byte[]"},{"DATA":"Education includes a BA in
    psychology from Colorado State University in 1970. She also completed
    "The Art of the Cold Call." Nancy is a member of Toastmasters
    International."},{"DATA":"2"},{"DATA":"http://accweb/emmployees/
    davolio.bmp"}]}, { "COL":[ {"DATA":"2"},{"DATA":"Fuller"},
    {"DATA":"Andrew"},{"DATA":"Vice President, Sales"},{"DATA":"Dr."},
    {"DATA":"2/19/1952 12:00:00 AM"},{"DATA":"8/14/1992 12:00:00 AM"},
    {"DATA":"908 W. Capital Way"},{"DATA":"Tacoma"},{"DATA":"WA"},
    {"DATA":"98401"},{"DATA":"USA"},{"DATA":"(206) 555-9482"},
    {"DATA":"3457"},{"DATA":"System.Byte[]"},{"DATA":"Andrew received his
    BTS commercial in 1974 and a Ph.D. in international marketing from the
    University of Dallas in 1981. He is fluent in French and Italian and
    reads German. He joined the company as a sales representative, was
    promoted to sales manager in January 1992 and to vice president of
    sales in March 1993. Andrew is a member of the Sales Management
    Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim
    Importers Association."},{"DATA":""},{"DATA":"http://accweb/emmployees/
    fuller.bmp"}]}, { "COL":[ {"DATA":"3"},{"DATA":"Leverling"},
    {"DATA":"Janet"},{"DATA":"Sales Representative"},{"DATA":"Ms."},
    {"DATA":"8/30/1963 12:00:00 AM"},{"DATA":"4/1/1992 12:00:00 AM"},
    {"DATA":"722 Moss Bay Blvd."},{"DATA":"Kirkland"},{"DATA":"WA"},
    {"DATA":"98033"},{"DATA":"USA"},{"DATA":"(206) 555-3412"},
    {"DATA":"3355"},{"DATA":"System.Byte[]"},{"DATA":"Janet has a BS
    degree in chemistry from Boston College (1984). She has also
    completed a certificate program in food retailing management. Janet
    was hired as a sales associate in 1991 and promoted to sales
    representative in February 1992."},{"DATA":"2"},{"DATA":"http://accweb/
    emmployees/leverling.bmp"}]}, { "COL":[ {"DATA":"4"},
    {"DATA":"Peacock"},{"DATA":"Margaret"},{"DATA":"Sales Representative"},
    {"DATA":"Mrs."},{"DATA":"9/19/1937 12:00:00 AM"},{"DATA":"5/3/1993
    12:00:00 AM"},{"DATA":"4110 Old Redmond Rd."},{"DATA":"Redmond"},
    {"DATA":"WA"},{"DATA":"98052"},{"DATA":"USA"},{"DATA":"(206)
    555-8122"},{"DATA":"5176"},{"DATA":"System.Byte[]"},{"DATA":"Margaret
    holds a BA in English literature from Concordia College (1958) and an
    MA from the American Institute of Culinary Arts (1966). She was
    assigned to the London office temporarily from July through November
    1992."},{"DATA":"2"},{"DATA":"http://accweb/emmployees/
    peacock.bmp"}]}, { "COL":[ {"DATA":"5"},{"DATA":"Buchanan"},
    {"DATA":"Steven"},{"DATA":"Sales Manager"},{"DATA":"Mr."},
    {"DATA":"3/4/1955 12:00:00 AM"},{"DATA":"10/17/1993 12:00:00 AM"},
    {"DATA":"14 Garrett Hill"},{"DATA":"London"},{"DATA":""},{"DATA":"SW1
    8JR"},{"DATA":"UK"},{"DATA":"(71) 555-4848"},{"DATA":"3453"},
    {"DATA":"System.Byte[]"},{"DATA":"Steven Buchanan graduated from St.
    Andrews University, Scotland, with a BSC degree in 1976. Upon joining
    the company as a sales representative in 1992, he spent 6 months in an
    orientation program at the Seattle office and then returned to his
    permanent post in London. He was promoted to sales manager in March
    1993. Mr. Buchanan has completed the courses "Successful
    Telemarketing" and "International Sales Management." He is fluent in
    French."},{"DATA":"2"},{"DATA":"http://accweb/emmployees/
    buchanan.bmp"}]}, { "COL":[ {"DATA":"6"},{"DATA":"Suyama"},
    {"DATA":"Michael"},{"DATA":"Sales Representative"},{"DATA":"Mr."},
    {"DATA":"7/2/1963 12:00:00 AM"},{"DATA":"10/17/1993 12:00:00 AM"},
    {"DATA":"Coventry House
    Miner Rd."},{"DATA":"London"},{"DATA":""},{"DATA":"EC2 7JR"},
    {"DATA":"UK"},{"DATA":"(71) 555-7773"},{"DATA":"428"},
    {"DATA":"System.Byte[]"},{"DATA":"Michael is a graduate of Sussex
    University (MA, economics, 1983) and the University of California at
    Los Angeles (MBA, marketing, 1986). He has also taken the courses
    "Multi-Cultural Selling" and "Time Management for the Sales
    Professional." He is fluent in Japanese and can read and write
    French, Portuguese, and Spanish."},{"DATA":"5"},{"DATA":"http://accweb/
    emmployees/davolio.bmp"}]}, { "COL":[ {"DATA":"7"},{"DATA":"King"},
    {"DATA":"Robert"},{"DATA":"Sales Representative"},{"DATA":"Mr."},
    {"DATA":"5/29/1960 12:00:00 AM"},{"DATA":"1/2/1994 12:00:00 AM"},
    {"DATA":"Edgeham Hollow
    Winchester Way"},{"DATA":"London"},{"DATA":""},{"DATA":"RG1 9SP"},
    {"DATA":"UK"},{"DATA":"(71) 555-5598"},{"DATA":"465"},
    {"DATA":"System.Byte[]"},{"DATA":"Robert King served in the Peace
    Corps and traveled extensively before completing his degree in English
    at the University of Michigan in 1992, the year he joined the
    company. After completing a course entitled "Selling in Europe," he
    was transferred to the London office in March 1993."},{"DATA":"5"},
    {"DATA":"http://accweb/emmployees/davolio.bmp"}]}, { "COL":
    [ {"DATA":"8"},{"DATA":"Callahan"},{"DATA":"Laura"},{"DATA":"Inside
    Sales Coordinator"},{"DATA":"Ms."},{"DATA":"1/9/1958 12:00:00 AM"},
    {"DATA":"3/5/1994 12:00:00 AM"},{"DATA":"4726 - 11th Ave. N.E."},
    {"DATA":"Seattle"},{"DATA":"WA"},{"DATA":"98105"},{"DATA":"USA"},
    {"DATA":"(206) 555-1189"},{"DATA":"2344"},{"DATA":"System.Byte[]"},
    {"DATA":"Laura received a BA in psychology from the University of
    Washington. She has also completed a course in business French. She
    reads and writes French."},{"DATA":"2"},{"DATA":"http://accweb/
    emmployees/davolio.bmp"}]}, { "COL":[ {"DATA":"9"},
    {"DATA":"Dodsworth"},{"DATA":"Anne"},{"DATA":"Sales Representative"},
    {"DATA":"Ms."},{"DATA":"1/27/1966 12:00:00 AM"},{"DATA":"11/15/1994
    12:00:00 AM"},{"DATA":"7 Houndstooth Rd."},{"DATA":"London"},
    {"DATA":""},{"DATA":"WG2 7LT"},{"DATA":"UK"},{"DATA":"(71) 555-4444"},
    {"DATA":"452"},{"DATA":"System.Byte[]"},{"DATA":"Anne has a BA degree
    in English from St. Lawrence College. She is fluent in French and
    German."},{"DATA":"5"},{"DATA":"http://accweb/emmployees/
    davolio.bmp"}]} ]}]}
    ShutterMan, Jul 26, 2008
    #1
    1. Advertising

  2. ShutterMan wrote:

    > I have a JSON object as below (data is from SQL Server Northwind
    > Database).  But doing an eval on it returns an error "unterminated
    > string constant" or such.  Can someone help me pinpoint the element
    > that is causing the grief?  Sorry to post the entire object, but Im
    > hoping someone has a parse utility that will help find whats wrong.


    You're using quotes inside quotes, please see:

    > { "TABLE":[{ "ROW":[ { "COL":[ {"DATA":"EmployeeID"},
    > {"DATA":"LastName"},{"DATA":"FirstName"},{"DATA":"Title"},
    > {"DATA":"TitleOfCourtesy"},{"DATA":"BirthDate"},{"DATA":"HireDate"},
    > {"DATA":"Address"},{"DATA":"City"},{"DATA":"Region"},
    > {"DATA":"PostalCode"},{"DATA":"Country"},{"DATA":"HomePhone"},
    > {"DATA":"Extension"},{"DATA":"Photo"},{"DATA":"Notes"},
    > {"DATA":"ReportsTo"},{"DATA":"PhotoPath"}]}, { "COL":[ {"DATA":"1"},
    > {"DATA":"Davolio"},{"DATA":"Nancy"},{"DATA":"Sales Representative"},
    > {"DATA":"Ms."},{"DATA":"12/8/1948 12:00:00 AM"},{"DATA":"5/1/1992
    > 12:00:00 AM"},{"DATA":"507 - 20th Ave. E.
    > Apt. 2A"},{"DATA":"Seattle"},{"DATA":"WA"},{"DATA":"98122"},
    > {"DATA":"USA"},{"DATA":"(206) 555-9857"},{"DATA":"5467"},
    > {"DATA":"System.Byte[]"},{"DATA":"Education includes a BA in
    > psychology from Colorado State University in 1970.  She also completed
    > "The Art of the Cold Call."  Nancy is a member of Toastmasters


    here

    > International."},{"DATA":"2"},{"DATA":"http://accweb/emmployees/
    > davolio.bmp"}]}, { "COL":[ {"DATA":"2"},{"DATA":"Fuller"},
    > {"DATA":"Andrew"},{"DATA":"Vice President, Sales"},{"DATA":"Dr."},
    > {"DATA":"2/19/1952 12:00:00 AM"},{"DATA":"8/14/1992 12:00:00 AM"},
    > {"DATA":"908 W. Capital Way"},{"DATA":"Tacoma"},{"DATA":"WA"},
    > {"DATA":"98401"},{"DATA":"USA"},{"DATA":"(206) 555-9482"},
    > {"DATA":"3457"},{"DATA":"System.Byte[]"},{"DATA":"Andrew received his
    > BTS commercial in 1974 and a Ph.D. in international marketing from the
    > University of Dallas in 1981.  He is fluent in French and Italian and
    > reads German.  He joined the company as a sales representative, was
    > promoted to sales manager in January 1992 and to vice president of
    > sales in March 1993.  Andrew is a member of the Sales Management
    > Roundtable, the Seattle Chamber of Commerce, and the Pacific Rim
    > Importers Association."},{"DATA":""},{"DATA":"http://accweb/emmployees/
    > fuller.bmp"}]}, { "COL":[ {"DATA":"3"},{"DATA":"Leverling"},
    > {"DATA":"Janet"},{"DATA":"Sales Representative"},{"DATA":"Ms."},
    > {"DATA":"8/30/1963 12:00:00 AM"},{"DATA":"4/1/1992 12:00:00 AM"},
    > {"DATA":"722 Moss Bay Blvd."},{"DATA":"Kirkland"},{"DATA":"WA"},
    > {"DATA":"98033"},{"DATA":"USA"},{"DATA":"(206) 555-3412"},
    > {"DATA":"3355"},{"DATA":"System.Byte[]"},{"DATA":"Janet has a BS
    > degree in chemistry from Boston College (1984).  She has also
    > completed a certificate program in food retailing management.  Janet
    > was hired as a sales associate in 1991 and promoted to sales
    > representative in February 1992."},{"DATA":"2"},{"DATA":"http://accweb/
    > emmployees/leverling.bmp"}]}, { "COL":[ {"DATA":"4"},
    > {"DATA":"Peacock"},{"DATA":"Margaret"},{"DATA":"Sales Representative"},
    > {"DATA":"Mrs."},{"DATA":"9/19/1937 12:00:00 AM"},{"DATA":"5/3/1993
    > 12:00:00 AM"},{"DATA":"4110 Old Redmond Rd."},{"DATA":"Redmond"},
    > {"DATA":"WA"},{"DATA":"98052"},{"DATA":"USA"},{"DATA":"(206)
    > 555-8122"},{"DATA":"5176"},{"DATA":"System.Byte[]"},{"DATA":"Margaret
    > holds a BA in English literature from Concordia College (1958) and an
    > MA from the American Institute of Culinary Arts (1966).  She was
    > assigned to the London office temporarily from July through November
    > 1992."},{"DATA":"2"},{"DATA":"http://accweb/emmployees/
    > peacock.bmp"}]}, { "COL":[ {"DATA":"5"},{"DATA":"Buchanan"},
    > {"DATA":"Steven"},{"DATA":"Sales Manager"},{"DATA":"Mr."},
    > {"DATA":"3/4/1955 12:00:00 AM"},{"DATA":"10/17/1993 12:00:00 AM"},
    > {"DATA":"14 Garrett Hill"},{"DATA":"London"},{"DATA":""},{"DATA":"SW1
    > 8JR"},{"DATA":"UK"},{"DATA":"(71) 555-4848"},{"DATA":"3453"},
    > {"DATA":"System.Byte[]"},{"DATA":"Steven Buchanan graduated from St.
    > Andrews University, Scotland, with a BSC degree in 1976.  Upon joining
    > the company as a sales representative in 1992, he spent 6 months in an
    > orientation program at the Seattle office and then returned to his
    > permanent post in London.  He was promoted to sales manager in March
    > 1993.  Mr. Buchanan has completed the courses "Successful
    > Telemarketing" and "International Sales Management."  He is fluent in


    here

    > French."},{"DATA":"2"},{"DATA":"http://accweb/emmployees/
    > buchanan.bmp"}]}, { "COL":[ {"DATA":"6"},{"DATA":"Suyama"},
    > {"DATA":"Michael"},{"DATA":"Sales Representative"},{"DATA":"Mr."},
    > {"DATA":"7/2/1963 12:00:00 AM"},{"DATA":"10/17/1993 12:00:00 AM"},
    > {"DATA":"Coventry House
    > Miner Rd."},{"DATA":"London"},{"DATA":""},{"DATA":"EC2 7JR"},
    > {"DATA":"UK"},{"DATA":"(71) 555-7773"},{"DATA":"428"},
    > {"DATA":"System.Byte[]"},{"DATA":"Michael is a graduate of Sussex
    > University (MA, economics, 1983) and the University of California at
    > Los Angeles (MBA, marketing, 1986).  He has also taken the courses
    > "Multi-Cultural Selling" and "Time Management for the Sales
    > Professional."  He is fluent in Japanese and can read and write


    here

    > French, Portuguese, and Spanish."},{"DATA":"5"},{"DATA":"http://accweb/
    > emmployees/davolio.bmp"}]}, { "COL":[ {"DATA":"7"},{"DATA":"King"},
    > {"DATA":"Robert"},{"DATA":"Sales Representative"},{"DATA":"Mr."},
    > {"DATA":"5/29/1960 12:00:00 AM"},{"DATA":"1/2/1994 12:00:00 AM"},
    > {"DATA":"Edgeham Hollow
    > Winchester Way"},{"DATA":"London"},{"DATA":""},{"DATA":"RG1 9SP"},
    > {"DATA":"UK"},{"DATA":"(71) 555-5598"},{"DATA":"465"},
    > {"DATA":"System.Byte[]"},{"DATA":"Robert King served in the Peace
    > Corps and traveled extensively before completing his degree in English
    > at the University of Michigan in 1992, the year he joined the
    > company.  After completing a course entitled "Selling in Europe," he


    here

    > was transferred to the London office in March 1993."},{"DATA":"5"},
    > {"DATA":"http://accweb/emmployees/davolio.bmp"}]}, { "COL":
    > [ {"DATA":"8"},{"DATA":"Callahan"},{"DATA":"Laura"},{"DATA":"Inside
    > Sales Coordinator"},{"DATA":"Ms."},{"DATA":"1/9/1958 12:00:00 AM"},
    > {"DATA":"3/5/1994 12:00:00 AM"},{"DATA":"4726 - 11th Ave. N.E."},
    > {"DATA":"Seattle"},{"DATA":"WA"},{"DATA":"98105"},{"DATA":"USA"},
    > {"DATA":"(206) 555-1189"},{"DATA":"2344"},{"DATA":"System.Byte[]"},
    > {"DATA":"Laura received a BA in psychology from the University of
    > Washington.  She has also completed a course in business French.  She
    > reads and writes French."},{"DATA":"2"},{"DATA":"http://accweb/
    > emmployees/davolio.bmp"}]}, { "COL":[ {"DATA":"9"},
    > {"DATA":"Dodsworth"},{"DATA":"Anne"},{"DATA":"Sales Representative"},
    > {"DATA":"Ms."},{"DATA":"1/27/1966 12:00:00 AM"},{"DATA":"11/15/1994
    > 12:00:00 AM"},{"DATA":"7 Houndstooth Rd."},{"DATA":"London"},
    > {"DATA":""},{"DATA":"WG2 7LT"},{"DATA":"UK"},{"DATA":"(71) 555-4444"},
    > {"DATA":"452"},{"DATA":"System.Byte[]"},{"DATA":"Anne has a BA degree
    > in English from St. Lawrence College.  She is fluent in French and
    > German."},{"DATA":"5"},{"DATA":"http://accweb/emmployees/
    > davolio.bmp"}]} ]}]}


    Hope this helps,

    --
    Bart
    Bart Van der Donck, Jul 26, 2008
    #2
    1. Advertising

  3. ShutterMan

    ShutterMan Guest

    Ah thank you. Im using an open source serializer, and apparently there
    is a bug in it. Can you tell me the appropriate way to signify quotes
    within? Should it be \" ?
    ShutterMan, Jul 26, 2008
    #3
  4. ShutterMan

    Jorge Guest

    On Jul 26, 9:46 pm, ShutterMan <> wrote:
    > Ah thank you. Im using an open source serializer, and apparently there
    > is a bug in it.  Can you tell me the appropriate way to signify quotes
    > within? Should it be \" ?


    Yes, \" or '. For example :

    javascript:jsonTxt= [ "The book 'Don Quijote de la Mancha'",
    'The book "Don Quijote de la Mancha"',
    'The book \'Don Quijote de la Mancha\'',
    "The book \"Don Quijote de la Mancha\"",
    'The book "Don Quijote de la Mancha"' ], jsonData= eval(jsonTxt);
    while(jsonData.length){alert(jsonData.pop())}

    --Jorge,
    Jorge, Jul 26, 2008
    #4
  5. ShutterMan

    Jorge Guest

    On Jul 26, 9:46 pm, ShutterMan <> wrote:
    > Can you tell me the appropriate way to signify quotes
    > within? Should it be \" ?


    Yes, \"

    --Jorge.
    Jorge, Jul 26, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Florian Frank
    Replies:
    0
    Views:
    229
    Florian Frank
    Jun 30, 2009
  2. sajuptpm
    Replies:
    2
    Views:
    316
    sajuptpm
    Dec 28, 2012
  3. Acácio Centeno
    Replies:
    1
    Views:
    241
    dieter
    Feb 15, 2013
  4. Bryan Britten
    Replies:
    9
    Views:
    257
    Bryan Britten
    May 28, 2013
  5. David Karr
    Replies:
    1
    Views:
    155
    David Karr
    Jun 17, 2013
Loading...

Share This Page