根据评论:
declare @astr varchar(max);
declare @start int;
declare @end int;
set @astr = '{"str":[1,1342886173,100000627571405,"offsite_conversion.lead",{"action.type":"offsite_conversion","conversion_event":387756207950188,"tag":"lead"},["conversion_event"],[],{"amount":12623486},"1:11:1:0:0:1:0"]}';
select @start = charindex('"conversion_event":',@astr)
select @end = charindex(',"tag":',@astr)
select substring(@astr,@start,@end-@start);
返回
"conversion_event":387756207950188
添加
set @start = @start + 19;
只得到号码。
SELECT substring('{"str":[1,1342886173,100000627571405,"offsite_conversion.lead",{"action.type":"offsite_conversion","conversion_event":387756207950188,"tag":"lead"},["conversion_event"],[],{"amount":12623486},"1:11:1:0:0:1:0"]}',
101,16);
或者
select substring('{"str":[1,1342886173,100000627571405,"offsite_conversion.lead",{"action.type":"offsite_conversion","conversion_event":387756207950188,"tag":"lead"},["conversion_event"],[],{"amount":12623486},"1:11:1:0:0:1:0"]}',
151,16)
好的,这是对象的结构:
{
"str":[1,
1173,
10005,
"offsite_conversion.lead",
{"action.type":"offsite_conversion",
"conversion_event":387756207950188,
"tag":"lead"},
["conversion_event"],
[],
{"amount":14486},
"1:11:1:0:0:1:0"
]}
str
具有数组属性的对象。
第5个元素有第2个属性转换事件
第 6 个元素是一个元素的数组,它是转换事件。
所以问题是……这个结构是一样的吗?你想要哪一个?