用于从嵌入在XML中的JSON获取值的脚本

时间:2014-06-16 00:12:47

标签: xml json ssis

有谁知道如何从嵌入在XML中的JSON中获取值并将其分配给SSIS中的变量?

我有一个创建具有JSON值的XML的作业,如下所示:

<string>
{"result_code":1,"result_message":"All calling list successfully retrieved records number","total_records":0,"total_processed":0,"total_excluded":0,"ResultCSV":null,"number_callinglist_records":6015}
</string>

下面是我用来从嵌入式JSON中获取"number_calling_list"值并将其分配给字符串变量的脚本:

Dim totalCount As String = ""
If FileContents.Contains("number_callinglist_records") = True Then
    totalCount = Dts.Variables("number_callinglist_records").Value
End If


If FileContents.Contains("number_callinglist_records") = True Then
    EmailMessage = "List count has been successfully, see attached file for details " + totalCount
Else : EmailMessage = "List count has been failed, please see attachment for details"

它不起作用,并在运行时显示以下错误消息:

  

Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException:元素   在集合中找不到。尝试时会发生此错误   在执行期间从容器上的集合中检索元素   包裹和元素不存在。

有谁知道为什么会发生这种情况以及如何从嵌入式JSON中获取"number_callinglist_records"值?

1 个答案:

答案 0 :(得分:0)

您的Dts.Variables引用看起来不对。我会改变:

Dts.Variables("number_callinglist_records").Value

Dts.Variables("User::number_callinglist_records").Value