我有一个这样的字符串:
{"Restriction":"<wbr><a href=\"https://www.google.com.tw/#q=%E4%B8%AD%E5%9C%8B\"
target=\"_blank\"><span style=\"color: rgb(0, 0, 205);\">more info</span></a></wbr>"}
Run Code Online (Sandbox Code Playgroud)
但我无法用 JSON.parse 解析它。我的代码如下所示:
var s = '{"Restriction":"<wbr><a href=\"https://www.google.com.tw/#q=%E4%B8%AD%E5%9C%8B\" target=\"_blank\"><span style=\"color: rgb(0, 0, 205);\">more info</span></a></wbr>"}';
var obj = JSON.parse(s);
Run Code Online (Sandbox Code Playgroud)
我得到了错误:
未捕获的语法错误:意外的标记。
我的猜测是 ?\"? 出了点问题,但我无法更改字符串,因为我是通过调用远程 API 获得的。这是我的代码:
// We need this to build our post string
var querystring = require('querystring');
var http = require('http');
var fs = require('fs');
function PostCode(codestring) {
// An object of options to indicate where to post to
var post_options = {
host: 'api.domain',
port: '80',
path: '/webservice/service.asmx/method?key=123456',
method: …Run Code Online (Sandbox Code Playgroud) 我有一个表使用id和DateTime列是pk,但当我尝试通过Entity Framework更新数据时,如下所示:
using (Entities context = new Entities())
{
var item = (from item in context.BatchData
where item.Id == 2
select item ).FirstOrDefault();
item.Title = "EF6TEST";
context.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误
存储更新,插入或删除语句会影响意外的行数(0).
记录SQL后,我知道原因.
SQL看起来像这样
'update [dbo].[BatchData]
set [BatchData_Title] = @0
where (([BatchData_Id] = @1) and ([BatchData_CreatedDateTime] = @2))
select [BatchData_Rowversion]
from [dbo].[BatchData]BatchUploadData
where @@ROWCOUNT > 0 and [BatchData_Id] = @1 and [BatchData_CreatedDateTime] = @2',
N'@0 varchar(30),@1 tinyint,@2 datetime2(7)',
@0='EF6TEST',@1=1,@2='2017-09-16 11:29:35.3720000'
Run Code Online (Sandbox Code Playgroud)
所以,原因是BatchData_CreatedDateTimeSQL中的参数是@2='2017-09-16 11:29:35.3720000',精度是7,它应该是@2='2017-09-16 11:29:35.372'.
这是我的问题,如何解决?