【问题标题】:Json.Net.Schema error when two string arrays两个字符串数组时出现 Json.Net.Schema 错误
【发布时间】:2015-09-09 21:22:11
【问题描述】:

当我尝试使用两个 string[] 或两个 List 打印架构时出现错误。 string[] 和 List 都可以。

在目标类中有这个。

public string[] ovoList;
public string[] procList;

在架构转换为字符串而不是在其生成位置的行上导致错误。

        static void Main(){
        JSchemaGenerator generator = new JSchemaGenerator();

        JSchema schema = generator.Generate(typeof(UNIKK.UIEngine.UIFrame));
        //Error is thrown on two lines below 
        Console.WriteLine(schema);
        File.WriteAllText(@"OVOSchema.json", schema.ToString());

我尝试了 Newtonsoft.JSON 6.0.8 和最新的 7.x 以及 Newtonsoft.JSON.Schema 1.0.11 我用 nuget 抓住了它们并正在运行 Xamarin 工作室 版本 5.9.5(构建 10) 单声道 4.0.3 ((分离/d6946b4) 在 OS X 上

错误跟踪是

System.Uri.EnsureAbsoluteUri () 在 /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-根/mono-4.0.3/mcs/class/System/System/Uri.cs:2062 System.Uri.GetComponents (components=System.UriComponents.Host|System.UriComponents.Port|System.UriComponents.Scheme|System.UriComponents.UserInfo, format=System.UriFormat.Unescaped) 在 /private/tmp/source-mono- mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs: 1731 System.Uri.Compare (uri1={#}, uri2={#/properties/ovoList},partsToCompare=System.UriComponents.Host|System.UriComponents.Port|System.UriComponents.Scheme|System.UriComponents.UserInfo, compareFormat= System.UriFormat.Unescaped, comparisonType=System.StringComparison.InvariantCultureIgnoreCase) 在 /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac- xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:1768 System.UriParser.IsBaseOf (baseUri={#}, relativeUri={#/properties/ovoList}) 在 /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-分支/配置文件/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/UriParser.cs:208

System.Uri.IsBaseOf (uri={#/properties/ovoList}) 在 /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles /mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:1740

【问题讨论】:

    标签: mono json.net


    【解决方案1】:

    问题是没有Id。 scheme.ToString 函数希望 procList 属性引用 ovoList 属性,但它无法创建 ref,因为没有架构的基本 URI。

    添加

    schema.Id = new Uri ("http://www.example.com/"); 
    

    解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多