Json 배열을 deserialize하려고하지만 작동하지 않습니다. I 출력 상자에 다음과 같은 메시지를 읽을 수 있습니다 :C#에서 Newtonsoft를 사용하여 JSON 배열을 비 직렬화
"Newtonsoft.Json.JsonReaderException : 잘못된 자바 스크립트 속성 식별자 문자 '. 경로'[0] ', 2 호선, 위치 37"
내 코드 : 당신의 도움에 대한
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Newtonsoft;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JsonTest
{
[Activity(Label = "JsonTest", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate
{
string json = @"[{
id': '1',
'nom': 'zooz',
'prenom': 'Jack'
}, {
'id': '2',
'nom': 'toto',
'prenom': 'Blaireau'
}]";
var a = JsonConvert.DeserializeObject<List<Person>>(json);
//JArray b = JArray.Parse(json);
Console.WriteLine(a);
// [email protected]};
};
}
public class Account
{
public string id { get; set; }
public string nom { get; set; }
public string prenom { get; set; }
}
public class Person
{
public Account person;
}
}
}
감사합니다.
에 성공적으로 직렬화한다 ''1 '을 – hellowstone
감사를. 그것은 어리석은 실수였다. 이 경우의 – Matthaousse