安裝教學
https://youtu.be/WujKlfNyL8I
序列化
#include <string>
using namespace std;
using namespace System;
using namespace Newtonsoft::Json;
public ref class Account : Object
{
public:
bool Active;
String^ Email;
};
int main()
{
Account^ account = gcnew Account();
account->Email = "kaihao@example.com";
account->Active = true;
String^ json = JsonConvert::SerializeObject(account, Formatting::Indented);
Console::WriteLine(json);
Console::ReadKey();
return 0;
}
反序列化
#include <string>
using namespace std;
using namespace System;
using namespace System::IO;
using namespace System::Collections::Generic;
using namespace Newtonsoft::Json;
public ref class PeopleData : Object
{
public:
String^ Part;
List<List<float>^>^ Points;
};
int main()
{
String^ jsonFile = File::ReadAllText(R"(C:\Users\KaiHao\Desktop\1GM318J6\size.txt)");
List<PeopleData^>^ peopleDatas = JsonConvert::DeserializeObject<List<PeopleData^>^>(jsonFile, (JsonSerializerSettings ^)nullptr);
Console::ReadKey();
return 0;
}
沒有留言:
張貼留言