lazarus中json解析时“string exceeds end of line”错误

Lazarus 0.9.31

jp:=TJSONParser.Create(UTF8Encode(pl));
try
   adList:=jp.Parse as TJSONArray;  

报错:

An exception was raised on the server: string exceeds end of line

其中,pl包含从memo中返回的text值,用superobject的asjson(false,false)编码

其实,就是包含了”’#10’”的字符

 

 

原因:

参考:

Lazarus的 文档:Scanner messages.  

http://www.freepascal.org/docs-html/user/userse61.html

Fatal: String exceeds line

There is a missing closing ’ in a string, so it occupies multiple lines.

可见,是因为回车中的换行字符的单引号引起的。

 

解决办法:

使用tstrings的commatext属性代替text属性即可。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据