![](/img/trans.png)
[英]Enum response is numeric value and not string
對於我所有其他枚舉類 swagger 顯示字符串定義,但對於我在“ExceptionMiddleware”class 中使用的一個枚舉 class,它顯示數值。 但在 swagger 文檔示例中,它顯示了字符串值.. 我的枚舉 class: 我的其他枚舉類之一沒有這個“問題”: 找不到合約時的結果 ...
[英]Enum response is numeric value and not string
對於我所有其他枚舉類 swagger 顯示字符串定義,但對於我在“ExceptionMiddleware”class 中使用的一個枚舉 class,它顯示數值。 但在 swagger 文檔示例中,它顯示了字符串值.. 我的枚舉 class: 我的其他枚舉類之一沒有這個“問題”: 找不到合約時的結果 ...
[英]JsonSerializer.DeserializeAsync<T> no error, no exception, no result
在 my.NET MAUI 應用程序中,我正在反序列化 http 響應: 在這種特殊情況下,T 是 List 的類型,例如: 我有來自服務器的響應,結果是 200,響應中有內容,但是當行var result = await JsonSerializer.DeserializeAsync(stream ...
[英]System.Text.Json.JsonException: The JSON value could not be converted to System.Collections.Generic.List`1[System.Collections.Generic.List`1
我是 C# 開發的初學者,我需要你的幫助。我正在檢查 Stackoverflow 中的所有主題,但找不到並解決我的問題。 我收到一個 API 的 JSON 響應,我想轉換 object 中的數據。 ----------這里是我的 JSON 回復: ----------如果我用 JObject. ...
[英]Why is my JSON serializer giving a 500 error when changing property from byte[] to List<byte[]>?
我使用純 JSON 輸入和 Base64 編碼圖像上傳圖像。 當我使用 byte[] 類型的屬性時,代碼運行良好但是當我想在一個 go 中支持上傳多個文件並將屬性更改為 List<byte[]> 時,我得到如下 500 錯誤 我假設問題出在我的序列化程序方法中,如下所示 序列化器應用於 ...
[英]json Deserialize dynamic to convert it to model
我正在嘗試轉換 到 model class 即 AdvanceEventsDto EventDto 類是 json 是 當我試圖獲得如下值時 但我收到以下錯誤The requested operation requires an element of type 'Array', but the ...
[英]How do I use Active-record-serializer to compose custom JSON data
我有以下模型和序列化器。 我想要這樣一種情況,當我向我的 List Controller index發出請求時,我得到Expected Json 。 請看下面: 在這里查看我的數據庫關聯圖預計JSON 楷模 序列化器 我已經描述了我上面的嘗試。 ...
[英]Deserializing array of JSONElement back to a concrete list not working when using System.Text.Json
反序列化對象時遇到問題。 該對象有一個屬性( data ),它是一個JSONElement列表。 我正在做: 序列化result變量具有以下內容: 而MyItem類如下: data變量是一個包含x項的列表。 但是,所有項目都是空實例。 我究竟做錯了什么? ...
[英]I am trying to get a list of objects to pass to my screen, but I keep getting a type cast error
這是我的Product類別: 我返回產品列表的功能是 我正在嘗試從遠程 API 解析數據,然后將 JSON 數據轉換為產品列表。 我一直收到錯誤 [錯誤:flutter/runtime/dart_vm_initializer.cc(41)] 未處理的異常:類型“String”不是類型轉換中類型“in ...
[英]jsonserializer.serialize library failed
我有一個 Asp.Net Core Mvc 項目。 我想使用 JsonSerializer class 將數據發送到另一個 Action。但是在 Serializer 方法的重載中,沒有只需要一個值的方法。 我想知道我需要為 Visual Studio 添加什么 package? 序列化下面有一條 ...
[英]JSONSerializer.toJSON ignores key 'class'
如果 JSON 字符串包含“類”鍵,如何使用 JSONSerializer 將 JSON 字符串轉換為 JSON? 通過使用 toJSON 方法,所有“類”鍵都將被忽略:String str = "{'test': 'ok', 'class' : 'fail'}"; JSON json = JSO ...
[英]Can I configure asp.net so some responses are serialized as camelCase and some as PascalCase?
我有一個 API,有兩個客戶端:OldClient 和 newClient。 我目前在Startup.cs中有這個,所以我的 json 響應被序列化為 PascalCase,即根據我所有的首字母大寫的 .net 對象。 OldClient 喜歡這種格式。 但是,newClient 確實更喜歡駝峰 ...
[英]kotlin: nested polymorphic serialization with generics
我想序列化 Map<String, Any> 並且值類型之一是 Pair<Int, Int>。 如何將 Pair 注冊為多態子類? 應該像這樣編碼為 json: 但是產生如下錯誤: 線程“主”中的異常 java.lang.ExceptionInInitializerError ...
[英]JsonResult object to JObject
我發現了一個問題,我很感興趣從JsonResult object 和JObject創建的最佳解決方案是什么。 JsonResult是這樣創建的: 它的值在字符串表示中如下所示: 我需要更改其中的一些屬性,json,,。 因為它不是有效的 json 字符串,我無法反序列化它。 是否有任何內置庫或其 ...
[英]springboot kafka value.serializer = StringSerializer despite producerConfig and the application.yml showing otherwise
我的 Kafka 制作人遇到了麻煩。 出於某種原因,value.serializer 被設置為 StringSerializer,盡管我在 producerConfig 和 application.yml 中都將其設置為 JsonSerializer,如下所示 再次在 application.yml ...
[英]How to create a JSON stream of UTF8 bytes in C#
我正在嘗試為內部使用的 stream 的擴展方法編寫單元測試 @this 將是我的 stream 我試過了 ''' var dog = new Dog() { Name = "Merlina" }; ''' 但是當試圖反序列化它時,我收到以下錯誤消息: 消息:System.Text.Json ...
[英]How to Set JSON PropertyNamingPolicy when using Results.OK in Minimal API when JsonSerializerOptions.PropertyNamingPolicy has no effect?
我正在使用 Minimal API 來重新創建舊的 REST 服務,因此我需要盡可能地模仿以前服務的功能。 舊服務中的信息返回 Pascal 大小寫,我知道有一些舊客戶端是區分大小寫的。 開箱即用的 .NET 6 序列化為 web 上的駝峰式外殼,但可以使用以下代碼覆蓋: 如果設置了斷點,我可以看 ...
[英]How to add indentation to JSON string to fix formatting using JsonSerializer?
web 服務正在向我發送 JSON 字符串。 它包含一個有效的 JSON 字符串,但它的格式很差。 有沒有辦法可以格式化它以更好地顯示在屏幕上? 我希望應用這樣的東西: ,但我找不到 API 來做這件事......有什么建議嗎? 謝謝。 ...
[英]How to read JSON value for single value?
我有一個應用程序返回以下 JSON 格式,只有 1 個值: 我可以通過將其放入字典中來讀取該值,如下所示: 但這似乎不是使用字典存儲單個鍵/值的好方法。 有沒有更好的方法從 JSON 中獲取價值? ...
[英]how to deserialize the property which has xml value but rest are json values
我有一個 azure 函數,它接收如下請求。 屬性之一具有 xml 值。 但是當我將它反序列化為 json 時,我得到了錯誤。 ...
[英]How to deserialize into collection of base type and then convert them to the concrete classes
我有一個字符串,我需要將其反序列化為一組對象,所有對象都繼承同一個基類。 我的問題是,在我反序列化為基類集合后,編譯器不會將每個項目識別為相關的具體對象。 這是我的代碼: 還有其他方法嗎? ...