Closed roasted-potatoe closed 7 years ago
I dont know how do you parse..... But i would do it easily like this:
Instead of Console.WriteLine(...) you can use Debug.Log(...)
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
class Program {
static void Main(string[] args) {
Response respo = JsonConvert.DeserializeObject<Response>(File.ReadAllText("data.json").ToString());
Console.WriteLine("Token: " + respo.accessToken.token);
Console.WriteLine("Version: " + respo.gameConfig.version);
Console.WriteLine("maxGold: " + string.Join(", ", respo.gameConfig.balancing.maxGold.ToArray()));
Console.ReadLine();
}
}
public class Response {
[JsonProperty(PropertyName = "gameConfig", Required = Required.Always)]
public GameConfig gameConfig;
[JsonProperty(PropertyName = "accessToken", Required = Required.Always)]
public AccessToken accessToken;
}
public class GameConfig {
[JsonProperty(PropertyName = "version", Required = Required.Always)]
public long? version;
[JsonProperty(PropertyName = "balancing", Required = Required.Always)]
public GameConfigBalancing balancing;
}
public class GameConfigBalancing {
[JsonProperty(PropertyName = "maxGold", Required = Required.Always)]
public List<double?> maxGold;
}
public class AccessToken {
[JsonProperty(PropertyName = "token", Required = Required.Always)]
public string token;
}
PS: see #7 too.
@beniben It seems that a JIT problem is there around handling List<double?>
. Adding AotHelper.EnsureList<double?>()
at your main function will solve this problem. (Check out FAQ part of README)
Thanks, that was the solution to the problem. I really appreciate the help, and am also sorry that I didn't check the FAQ first!
Hi,
We have a problem with your package with regards to lists and iOS. We use Unity 5.3.6f1 and build iOS with ILL2CPP.
This is our JSON :
These are our classes :
And this is the error callstack that we receive :
Are we doing anything wrong with our JSON? Is there something else than JsonConvert.DeserializeObject(json) that we should use to make it work?
Any help would be appreciated. Thank you.