Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > JSON parse failure - please help

Reply
Thread Tools

JSON parse failure - please help

 
 
ShutterMan
Guest
Posts: n/a
 
      07-26-2008
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":"Not es"},
{"DATA":"ReportsTo"},{"DATA":"PhotoPath"}]}, { "COL":[ {"DATA":"1"},
{"DATA":"Davolio"},{"DATA":"Nancy"},{"DATA":"Sa les 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":"981 22"},
{"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":"Sa les 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"},{"DA TA":"(206)
555-8122"},{"DATA":"5176"},{"DATA":"System.Byte[]"},{"DATA":"Margaret
holds a BA in English literature from Concordia College (195 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":"Sale s 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"}]} ]}]}
 
Reply With Quote
 
 
 
 
Bart Van der Donck
Guest
Posts: n/a
 
      07-26-2008
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":"Not es"},
> {"DATA":"ReportsTo"},{"DATA":"PhotoPath"}]}, { "COL":[ {"DATA":"1"},
> {"DATA":"Davolio"},{"DATA":"Nancy"},{"DATA":"Sa les 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":"981 22"},
> {"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":"Sa les 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"},{"DA TA":"(206)
> 555-8122"},{"DATA":"5176"},{"DATA":"System.Byte[]"},{"DATA":"Margaret
> holds a BA in English literature from Concordia College (195 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":"Sale s 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
 
Reply With Quote
 
 
 
 
ShutterMan
Guest
Posts: n/a
 
      07-26-2008
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 \" ?
 
Reply With Quote
 
Jorge
Guest
Posts: n/a
 
      07-26-2008
On Jul 26, 9:46*pm, ShutterMan <(E-Mail Removed)> 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,
 
Reply With Quote
 
Jorge
Guest
Posts: n/a
 
      07-26-2008
On Jul 26, 9:46*pm, ShutterMan <(E-Mail Removed)> wrote:
> Can you tell me the appropriate way to signify quotes
> within? Should it be \" ?


Yes, \"

--Jorge.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lib to generate XML/JSON[P] output from a DTD/XSD/JSON Schema/etc Acácio Centeno Python 1 02-15-2013 07:34 AM
I am facing an issue while decoding json string using json.loads sajuptpm Python 2 12-28-2012 07:16 AM
[ANN] Security Fix json-1.1.7 for json_pure and json gems Florian Frank Ruby 0 06-30-2009 05:18 PM
"JSON for ASP" at json.org Tuğrul Topuz ASP General 1 06-27-2008 11:37 PM
Syck parse error for JSON Gavri Fernandez Ruby 0 03-25-2006 12:13 PM



Advertisments