【发布时间】:2018-04-17 09:51:20
【问题描述】:
我正在从服务器获取响应:
{
"auth_token": "062450b9dd7e189f43427fbc5386f7771ba59467"
}
为了访问它,我需要使用与原始 JSON 相同的名称。
[System.Serializable]
public class TokenResponse
{
public string auth_token; // I want to rename it to authToken without renaming corresponding field in json
public static TokenResponse CreateFromJSON(string json) {
return JsonUtility.FromJson<TokenResponse>(json);
}
}
如何在不丢失功能的情况下将 TokenResponse.auth_token 重命名为 TokenResponse.authToken?
【问题讨论】:
-
[JsonProperty("auth_token")]public string AuthToken {get;set};(如果你使用 Json.Net) -
不,我正在使用 Mono (Unity3d)
标签: c# json unity3d mono deserialization