我已经对我的应用程序进行了几周的编码,当这个错误突然出现时,一切正常。我能够将错误的原因缩小到这一行:
var subscriptions = JsonConvert.DeserializeObject<SubscriptionList>(json);
我的反序列化在过去一直运作良好,但现在它突然崩溃了。我在一个尝试中包围它并捕获一个JSONException,但不是异常捕获它我的应用程序只是崩溃。我知道这是这一行,因为当我评论它时,应用程序运行完美。我搜索了日志猫试图找到一个错误,这就是它
W/Binder ( 1168): Caught a RuntimeException from the binder stub implementation.
W/Binder ( 1168): java.lang.NullPointerException
W/Binder ( 1168): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
W/Binder ( 1168): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
W/Binder ( 1168): at android.os.Binder.execTransact(Binder.java:404)
W/Binder ( 1168): at dalvik.system.NativeStart.run(Native Method)
我正在尝试完全反序列化这个JSON
{"list":[{"appId":"urn:aid:f104430c-d4f9-4ae6-850d-304ded2a583b","updatedAt":"2018-06-01T19:52:14Z","businessId":"a7c8b6ae-70e3-4b77-be64-769938d611ed","createdAt":"2018-06-01T19:52:13Z","phase":"TRIAL","planId":"c8584ffd-545f-4e38-9e97-55337e6cefe4","subscriptionId":"ec3d1e84-2695-45a8-8450-72daae4e2b30","startAt":"2018-06-01T00:00:00Z","status":"ACTIVE","replace":false,"bundled":false}],"start":0,"total":1}
这是我的类,一个名为SubscriptionList,一个名为Subscription
class SubscriptionList
{
[JsonProperty("list")]
public List<Subscription> list = new List<Subscription>();
[JsonProperty("start")]
public int start;
[JsonProperty("total")]
public int total;
[JsonProperty("count")]
public int count;
public SubscriptionList(List<Subscription> list,int s,int t,int count)
{
this.count = count;
this.list = list;
start = s;
total = t;
}
}
public class Subscription
{
[JsonProperty("businessId")]
public string businessId { get => businessId; set => businessId = value; }
[JsonProperty("planId")]
public string planId { get => planId; set => planId = value; }
[JsonProperty("subscriptionId")]
public string subscriptionId { get => subscriptionId; set => subscriptionId = value; }
[JsonProperty("appId")]
public string appId;
[JsonProperty("phase")]
public string phase;
[JsonProperty("replace")]
public bool replace;
[JsonProperty("bundled")]
public bool bundled;
[JsonProperty("status")]
public string status;
public Subscription(string bus,string plan,string sub)
{
businessId = bus;
planId = plan;
subscriptionId = sub;
}
}
即使在我调用此方法之前,我正在对应用程序中的其他任何地方进行反序列化。最让我困扰的是,我无法找到一个简单的JSON错误。谢谢。