int 数据类型不支持 JSON 类型 -->不支持 JSON 类型。 (参数“ValueKind”)\r\n实际值为 Number

发布于 2025-01-17 11:06:07 字数 2486 浏览 4 评论 0 原文

我有一个 person 具有 age 属性的类,该属性是 int 。它持续到宇宙图DB。我使用gremlinclient来获取记录,然后我有一个 aboritize 方法来重建< t> 。如果 Person 类没有任何 int 类型,则可以正常工作,但是我的方法在某个地方失败。

从图中回来,我的结果看起来不错:

”“在此处输入图像说明”

关于上述内容的几件事:

  1. 它是 idictionary< string,object> ,并且它具有4个条目。
  2. 第四个条目实际上保留了 person 对象的属性,因为它们存在于图中的 vertex 几乎没有什么要注意的:
  3. 尽管字典条目中的结果值( object )是一个值“鲍勃”,“橡木” ,32等。它来自Gremlin Client作为 system.linq.enumoblect.selectenumoserator< system.text.json.jsonelement,object> 我的方法试图提取该值,然后再提取该值,然后重新恢复< t> 和返回 t

这就是我找到的。 >我已经对此方法进行了一些更改,但它仍然会遇到相同的错误,显然它的 selectEnumoseratiterator 由于某种原因不喜欢 int s。

希望你们中的一个能帮助我!

错误和堆栈跟踪:

    ActualValue: Number
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233086
    HelpLink: null
    InnerException: null
    Message: "JSON type not supported. (Parameter 'ValueKind')\r\nActual value was Number."
    ParamName: "ValueKind"
    Source: "Gremlin.Net"
    StackTrace: "   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.<ReadDictionary>b__6_1(JsonProperty property)
\r\n   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
\r\n   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadDictionary(JsonElement jsonDict)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.<ToObject>b__4_0(JsonElement t)
\r\n   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()"    TargetSite: {System.Object ToObject(System.Text.Json.JsonElement)}

I have a class Person that has an Age property which is an int. It is persisted down to Cosmos Graph DB. I use the GremlinClient to fetch the record and then I have a Materialize method to rebuild <T>. If the Person class doesn't have any int types it works fine, however my method fails somewhere.

Coming back from the Graph, my result looks good:

enter image description here

Few things to note about the above:

  1. it is an IDictionary<string, object> and it has 4 entry.
  2. the 4th entry actually holds the properties of the Person object as they exist in the vertex in the graph
    enter image description here
    Few things to note:
  3. Although the resulting value in the dictionary entry (object) is a value "Bob", "Oak
    , 32, etc. it comes from the Gremlin client as System.Linq.Enumerable.SelectEnumerableIterator<System.Text.Json.JsonElement, object> which my method attempts to extract the value and then recreate <T> and return T.

Here's how I found it.link I have made some changes to this method but it still throws the same error, apparently its the SelectEnumerableIterator doesn't like Ints for some reason.

Hoping one of you can help me!

Error and Stack Trace:

    ActualValue: Number
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233086
    HelpLink: null
    InnerException: null
    Message: "JSON type not supported. (Parameter 'ValueKind')\r\nActual value was Number."
    ParamName: "ValueKind"
    Source: "Gremlin.Net"
    StackTrace: "   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.<ReadDictionary>b__6_1(JsonProperty property)
\r\n   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
\r\n   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ReadDictionary(JsonElement jsonDict)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.ToObject(JsonElement graphSon)
\r\n   at Gremlin.Net.Structure.IO.GraphSON.GraphSONReader.<ToObject>b__4_0(JsonElement t)
\r\n   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToList()"    TargetSite: {System.Object ToObject(System.Text.Json.JsonElement)}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呢古 2025-01-24 11:06:07

此处对同一问题进行了讨论,我已发布直到 Cosmos 更新他们的支持之前的解决方法。

There's a discussion on the same issue here, and I've posted a work-around until Cosmos updates their support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文