【发布时间】:2020-01-18 14:43:44
【问题描述】:
运行 Visual Studio Mac 的当前预览频道,v8.3 build 1630,我的 Xamarin.Android 应用报告了 Newtonsoft.Json.JsonReaderException。
以下代码在 Visual Studio for Mac v8.2.6(内部版本 28)的当前 Stable 通道中运行良好。
我需要为 VS for Mac v8.3 更新一些内容吗?
代码
readonly static HttpClient _client = new HttpClient();
public static async Task<MyModel> GetModelFromApi()
{
using (var response = await _client.GetAsync("https://my.api.url/endpoint").ConfigureAwait(false))
{
var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return JsonConvert.DeserializeObject<MyModel>(json);
}
}
堆栈跟踪
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: �. Path '', line 0, position 0.Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: �. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue () [0x002b3] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonTextReader.Read () [0x0004c] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonReader.ReadAndMoveToContent () [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonReader.ReadForType (Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) [0x0004a] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x000db] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00054] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x0002d] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) [0x00000] in <12891e825fce44a581e5bbbb579c1d49>:0
at JsonParseTextRepro.ApiService.GetPun () [0x0013f] in <a23104cc471e42a78acea59e0c31e721>:0
at JsonParseTextRepro.App+DemoPage.OnAppearing () [0x00091] in <a23104cc471e42a78acea59e0c31e721>:0
环境信息
=== Visual Studio Enterprise 2019 for Mac(预览版)===
8.3 版预览版(8.3 build 1630) 安装UUID:6e5142b4-e8be-4d1c-b75e-4744b0d8c3de GTK+ 2.24.23(罗利主题) Xamarin.Mac 5.16.1.24 (d16-3 / 08809f5b)
=== Xamarin.Android ===
版本:10.0.0.40(Visual Studio 企业版) 提交:xamarin-android/d16-3/080eaac Android SDK:/Users/brandonm/Library/Developer/Xamarin/android-sdk-macosx 支持的安卓版本: 没有安装
SDK 工具版本:26.1.1 SDK平台工具版本:28.0.2 SDK 构建工具版本:28.0.3
构建信息: 单声道:单声道/单声道@6434153 Java.Interop:xamarin/java.interop@5836f58 LibZipSharp: grendello/LibZipSharp/d16-3@71f4a94 LibZip: nih-at/libzip@b95cf3f ProGuard:xamarin/proguard@905836d SQLite:xamarin/sqlite@8212a2d Xamarin.Android 工具:xamarin/xamarin-android-tools@cb41333
【问题讨论】:
标签: xamarin.android visual-studio-mac