JSON parse failure - please help

S

ShutterMan

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"}]} ]}]}
 
B

Bart Van der Donck

ShutterMan said:
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,
 
S

ShutterMan

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 \" ?
 
J

Jorge

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,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,730
Latest member
AudryNolan

Latest Threads

Top