为什么我无法反序列化刚刚序列化的对象?

2023-12-26

Dim serialized = Newtonsoft.Json.JsonConvert.SerializeObject(gridOrderNewState)
Dim gridOrderNewstate2 = Newtonsoft.Json.JsonConvert.DeserializeObject(Of gridTradingState)(serialized)

结果几乎是空版本gridOrderNewstate2

这就是序列化后的值

{
   "bidInBase":0.99055,
   "askInBase":0.99333,
   "high":0.99448,
   "low":0.97528,
   "dateSinceLastTransactions":"2022-11-14T21:04:34.0103292+07:00",
   "suggestedLow":0.0,
   "suggestedhigh":0.0,
   "Orders":[
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807874",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.25,
         "priceInBasecoin":1.0,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":true,
         "marketURL":"https://gate.io/trade/frax_usdt"
      },
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807867",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.263,
         "priceInBasecoin":0.99778,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":true,
         "marketURL":"https://gate.io/trade/frax_usdt"
      },
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807859",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.277,
         "priceInBasecoin":0.99556,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":true,
         "marketURL":"https://gate.io/trade/frax_usdt"
      },
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807851",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.291,
         "priceInBasecoin":0.99333,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":true,
         "marketURL":"https://gate.io/trade/frax_usdt"
      },
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807835",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.334,
         "priceInBasecoin":0.98667,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":false,
         "marketURL":"https://gate.io/trade/frax_usdt"
      },
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807823",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.348,
         "priceInBasecoin":0.98444,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":false,
         "marketURL":"https://gate.io/trade/frax_usdt"
      },
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807816",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.363,
         "priceInBasecoin":0.98222,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":false,
         "marketURL":"https://gate.io/trade/frax_usdt"
      },
      {
         "time":"2022-11-14T13:09:54",
         "id":"227286807762",
         "customIdentifier":"t-FraxTest",
         "amountOfQuoteCurrencyBeingOrdered":6.377,
         "priceInBasecoin":0.98,
         "marketString":"gate",
         "Base":"USDT",
         "Quote":"FRAX",
         "isSellingInsteadOfBuying":false,
         "marketURL":"https://gate.io/trade/frax_usdt"
      }
   ]
}

很明显有些东西在那里。

但我无法反序列化为同一个对象类。

顺便说一句,这是班级

Class gridTradingState
    ReadOnly Property bidInBase As Decimal
    ReadOnly Property askInBase As Decimal
    ReadOnly Property high As Decimal
    ReadOnly Property low As Decimal
    ReadOnly Property dateSinceLastTransactions As Date
    ReadOnly Property suggestedLow As Decimal
    ReadOnly Property suggestedhigh As Decimal
    ReadOnly Property Orders As OrderAlreadyPlacedAtanExchange()

    Public Shared Function creategridTradingOldState(market As MarketPairInanExchange, ordersInp As OrderAlreadyPlacedAtanExchange()) As gridTradingState
        Dim currentState = New gridTradingState

        'currentState._bidInBase = market.askbidInBase(False)
        'currentState._askInBase = market.askbidInBase(True)
        currentState._bidInBase = market.bidInBaseCoin
        currentState._askInBase = market.askInBaseCoin
        currentState._high = market.highInBaseCoin
        currentState._low = market.lowInBaseCoin
        currentState._Orders = ordersInp

        currentState._dateSinceLastTransactions = Now
        Return currentState
    End Function

    Public Sub updateSuggestedLowandHigh(suggestedLowNew As Decimal, suggestedHighNew As Decimal)
        _suggestedLow = suggestedLowNew
        _suggestedhigh = suggestedHighNew
    End Sub
End Class

有人要求提供最低限度可重复的样本。我删除订单。序列化的内容变成

{
    "bidInBase": 0.98735,
    "askInBase": 0.9918,
    "high": 0.99448,
    "low": 0.97528,
    "dateSinceLastTransactions": "2022-11-14T22:47:47.5532599+07:00",
    "suggestedLow": 0.0,
    "suggestedhigh": 0.0
}

问题依然存在。看来 dbc 正在做某事


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么我无法反序列化刚刚序列化的对象? 的相关文章

随机推荐

  • 链接器输入文件未使用,因为链接未完成 - gcc

    我是编写 makefile 的初学者 我有一个类似这样的 makefile PATH1 ref CC gcc LINK gcc INCLUDES INCLUDES I PATH1 inc I PATH1 abc inc I PATH1 de
  • Modernizr 如何做边框半径

    你能帮我解释一下吗Modernizr 如果我使用某个功能 例如 border radius 我使用旧版浏览器运行它 现代化者是否会自动将 css 添加到页面 或者我应该编写代码来呈现控件以使其看起来像有边框一样 如果第二种情况属实 那么我为
  • 如何验证历史数据?

    目前 我们正在使用日历实例读取日期 以便使用 SparkSQL 选取最后一个月的记录 现在我们需要 如果在前一天添加额外的事件 我们还必须能够手动插入摘要开始和结束日期 以防我们需要手动重新运行之前时间段的作业 例如 手动重新运行表可能如下
  • HTML5 和 RDFa 支持

    我即将向现有的 HTML5 Web 应用程序引入开放图谱协议 并且我希望包含必要的 RDFa 数据 而不引入任何不必要的杂项 我看过HTML RDFa 1 1 http www w3 org TR rdfa in html 草稿并与Face
  • CSS 中内嵌的 SVG 图像

    这是一个基本的 SVG 图像悬停动画 有没有一种编码方法可以避免编写 SVG 代码两次 body background color 181818 a webkit transition all 3s ease moz transition
  • Pandas Concat 遇到内存错误

    我正在尝试预处理数据以进行进一步分析 首先 我从 csv 文件 x 中读取数据 然后我把它分成三个部分 最后我需要使用转换一个数组get dummies concat and sum的结果groupby import pandas as p
  • Android 中的静音流

    我构建了一个小应用程序 可以使用该类将音乐流静音 取消静音AudioManager 事实上 它一直有效 直到我关闭应用程序 即 我已将流静音 关闭应用程序 重新启动应用程序 并且按钮不再取消流静音 我在网上搜索过 但似乎没有人遇到过这个问题
  • 我应该使用哪种分层模型?邻接、嵌套还是枚举?

    我有一个表 其中包含世界上所有地理位置及其关系的位置 这是一个显示层次结构的示例 您将看到数据实际上存储为所有三个 枚举路径 邻接表 嵌套集 数据显然也永远不会改变 以下是英国布莱顿地点的直系祖先的示例 该地点的 woeid 为 13911
  • 使用 PDO 处理错误的最佳实践

    Problem 寻找使用 PDO 进行错误处理的最佳实践 我在网站 SO 书籍等上找到的选项 许多网站表示您应该在您的catch block SO 上的大量用户表示 由于安全风险 您永远不应该回显错误消息 其他人建议将其记录到文档根目录之外
  • 从 R 中用户定义的语料库中删除停用词

    我有一组文件 documents c She had toast for breakfast The coffee this morning was excellent For lunch let s all have pancakes L
  • 在 C# 中每行读取一个字符串行[重复]

    这个问题在这里已经有答案了 可能的重复 在 net中以换行符分割字符串的最简单方法 https stackoverflow com questions 1547476 easiest way to split a string on new
  • Devise:突然无法登录了

    我正在使用 Devise 1 3 4 对我的应用程序中的后端进行身份验证 我已经连续几天无法登录了 发生的情况是 我进入登录页面 admin sign in 使用良好的凭据登录 在日志中看到登录成功 last sign in at curr
  • Spring MutableValues 的 NoSuchMethodError

    我编写了一个测试 在其中使用注释指定应用程序上下文位置 然后我将我的 dao 自动连接到测试中 ContextConfiguration locations file service src main webapp WEB INF appl
  • 单选按钮在 Safari 和 Chrome 中不显示

    我对 html 和 css 的了解有限 如果这是一个愚蠢的问题 请原谅 我尝试了不同的方法 但无法解决这个问题 http teddyslist com dev register php http teddyslist com dev reg
  • 从 XML 字符串生成 XML 架构

    我有一个 XML 字符串 想要加载到 Excel 工作表中 我几乎已经让它工作了 但我需要能够生成传递给 XmlMaps Add 的架构 String xml This is already populated with an XML St
  • 在 GAE 上,如何根据正确的客户端时区显示日期?

    在我的 Google App Engine 应用程序上 我在模型中存储自动更新的日期 时间 如下所示 class MyModel db Model date db DateTimeProperty auto now add True 但是
  • 如果在子进程执行时执行 Ctrl+C,Python 是否总是引发异常?

    给出以下代码 try subprocess Popen ExternalProcess stdout subprocess PIPE stderr subprocess PIPE shell True communicate except
  • 如何有效地获取 10% 的随机数,然后获取剩余 90 个随机数的 10% 等,直到所有点都分配完毕

    这就是我想做的 我有30万积分 我想要10 的积分 然后我想要剩下90 的点中的10 然后我想要剩余 81 点中的 10 然后我想要剩余 73 点中的 10 等等 直到我完成所有要点 这是最快的方法吗 all the points s np
  • .net 4.5 和实体框架中的 OUTER APPLY

    安装后 Net 4 5 EF 生成的查询存在问题 linq to 中的相同查询 Net 4 0工作正常 我正在使用 Firebird 数据库 它不支持命令OUTER APPLY 有没有办法修改以下查询 linq 以便它的行为 Net 4 5
  • 为什么我无法反序列化刚刚序列化的对象?

    Dim serialized Newtonsoft Json JsonConvert SerializeObject gridOrderNewState Dim gridOrderNewstate2 Newtonsoft Json Json