c# - 在 C# 中将字符串转换为 json 格式。Newtonsoft.json 显示黄色标记
问题描述
我是 SSIS 的新手。我正在尝试将字符串转换为 JSON 格式,如图所示。我安装了 Newtonsoft Json。但它显示黄色三角形标记。
我已经安装了 Newtonsoft 的所有版本。但它仍然显示错误,而#
region Namespaces
using Newtonsoft.Json.Linq;
using System;
using System.Windows.Forms;#
endregion
namespace ST_9a0af2e4537b4d26adaef11149343faa {
public partial class ScriptMain: Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase {
public void Main() {
var myJsonString = "{report: {Id: \"aaakkj98898983\"}}";
MessageBox.Show(myJsonString);
try {
// when i add this line to my package then the package is not
excuting.if i remove this line then package is excuting.
JObject.Parse("{report: {\"Id\": \"aaakkj98898983\"}}");
} catch (Exception e) {
MessageBox.Show(e.ToString());
}
Dts.TaskResult = (int) ScriptResults.Success;
}
}
}
脚本任务。我的 IDE 版本是 Visual Studio 2015 Professional。
安装 Newtonsoft 后不显示。当我关闭脚本任务弹出窗口并再次打开脚本任务编辑器时,它显示黄色感叹号,当我选择 Newtonsoft 包并检查属性时,它的路径和版本显示 0.0.0.0。然后我下载了 Newtonsoft 包并引用 newtonsoft.json.dll 文件添加引用。然后它显示路径和版本。
但是当我运行包时它显示错误。
我也尝试按照文章进行操作,但没有成功。
将 JSON 字符串转换为 JSON 对象 c# https://www.c-sharpcorner.com/article/json-serialization-and-deserialization-in-c-sharp/ https://www.newtonsoft.com/json/help/html /M_Newtonsoft_Json_Linq_JObject_Parse.htm https://www.nuget.org/packages/System.Json/ 如何在没有 JSON.NET 库的情况下解析 JSON? 命名空间中不存在 Json 使用 SSIS 中的 C# 脚本解析 JSON 字符串 https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio https ://www.dotnetjalps.com/2014/04/converting-csharp-object-json-string.html 在 .Net 4.0 中找不到 JavaScriptSerializer
https://riptutorial.com/json-net/topic/1861/getting-started-with-json-net http://www.rockprogrammer.com/2017/08/how-to-install-json-.net- in-visual-studio-2015.htmls
有人可以帮我解决这个问题吗?
谢谢希夫罗伊
_
解决方案
谢谢大家 。
最后,我可以通过流动 Joost van Rossum 文章来解决问题。感谢 Joost van Rossum
将程序集添加到 GAC 在我们可以使用我们的程序集之前,我们必须将它添加到全局程序集缓存 (GAC)。再次打开 Visual Studio 2008 命令提示符(对于 Vista/Windows7/等,以管理员身份打开)。并执行以下命令。gacutil /id:\myMethodsForSSIS\myMethodsForSSIS\bin\Release\myMethodsForSSIS.dll
有关更多信息,请阅读本文 http://microsoft-ssis.blogspot.com/2011/05/referencing-custom-assembly-inside.html https://social.msdn.microsoft.com/Forums/sqlserver/en- US/d70cac36-6aa5-42cb-89a8-1a24cb5a0cad/cant-find-external-dll-reference-in-ssis-2012-script-task?forum=sqlintegrationservices
推荐阅读
- r - 更新数据框中的操作按钮
- django - 关系“”不存在
- oracle - 在交互式报告中显示来自 apex_application_temp_files 的图像
- python-3.x - 调用@classmethod 的super,它调用另一个classmethod
- compiler-errors - 为什么有些错误是无声的?
- javascript - 未捕获的 ReferenceError:未在 HTMLAnchorElement.onclick 中定义
- python - 从列表结果中选择 1 个特定值
- raku - Perl 6 阻塞等待被杀死的 Proc::Async
- c# - AutoMapper 更新嵌套集合
- python - 在 Flask 中组织蓝图特定配置