- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在使用 JSONSerializer 时遇到问题。我有这个方法:
public List<BusinessObject> transferToDomain(String pJSON) {
List<BusinessObject> lAllBusinessObject = new ArrayList<BusinessObject>();
if (null == pJSON || pJSON.equals("")) {
return lAllBusinessObject;
}
JSON lJSON = JSONSerializer.toJSON(pJSON);
if (lJSON.isEmpty()) {
return lAllBusinessObject;
} else {
if (lJSON.isArray()) {
JSONArray lJSONArray = (JSONArray) lJSON;
for (Object lObject : lJSONArray) {
JSONObject lJSONObject = (JSONObject) lObject;
lAllBusinessObject.add(doTransfer(lJSONObject));
}
} else {
JSONObject json = (JSONObject) lJSON;
BusinessObject lBusinessObject = doTransfer(json);
if (null != lBusinessObject) {
lAllBusinessObject.add(lBusinessObject);
}
}
}
return lAllBusinessObject;
}
它将 JSON 字符串转换为相关的业务对象。例如,使用该 Json-Code 行 JSONSerializer.toJSON(pJSon);
运行得很好:
[{"user":{"uid":51,"ustempel":0,"uname":"Stefan47"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":51,"rank":1,"sstempel":0,"model":"SCORE"},
{"user":{"uid":65,"ustempel":0,"uname":"Stefan61"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":65,"rank":2,"sstempel":0,"model":"SCORE"},
{"user":{"uid":66,"ustempel":0,"uname":"Stefan62"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":66,"rank":3,"sstempel":0,"model":"SCORE"},
{"user":{"uid":67,"ustempel":0,"uname":"Stefan63"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":67,"rank":4,"sstempel":0,"model":"SCORE"},
{"user":{"uid":68,"ustempel":0,"uname":"Stefan64"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":68,"rank":5,"sstempel":0,"model":"SCORE"},
{"user":{"uid":69,"ustempel":0,"uname":"Stefan65"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":69,"rank":6,"sstempel":0,"model":"SCORE"},
{"user":{"uid":70,"ustempel":0,"uname":"Stefan66"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":70,"rank":7,"sstempel":0,"model":"SCORE"},
{"user":{"uid":71,"ustempel":0,"uname":"Stefan67"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":71,"rank":8,"sstempel":0,"model":"SCORE"},
{"user":{"uid":72,"ustempel":0,"uname":"Stefan68"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":72,"rank":9,"sstempel":0,"model":"SCORE"},
{"user":{"uid":73,"ustempel":0,"uname":"Stefan69"
,"model":"USER"},"points":882,"level":27,"scomment":"Wuhuuuu"
,"sid":73,"rank":10,"sstempel":0,"model":"SCORE"}]
但使用 JSON 代码:
[{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":1,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"Die Bundesliga"
,"qid":1303,"qstempel":1390138057765,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":1,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"Premiure League"
,"qid":1636,"qstempel":1390138059690,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":3,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"WM"
,"qid":1582,"qstempel":1390138059395,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":3,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"Die Bundesliga"
,"qid":1421,"qstempel":1390138058497,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":3,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"Premiure League"
,"qid":1708,"qstempel":1390138060083,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":1,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"WM"
,"qid":1470,"qstempel":1390138058774,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":2,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"Premiure League"
,"qid":1667,"qstempel":1390138059857,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":2,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"WM"
,"qid":1539,"qstempel":1390138059158,"model":"QUESTION"},
{"question":"Wer bist Du?"
,"answer1":"Jens"
,"answer2":"Anja"
,"answer3":"Stefan"
,"answer4":"Willi"
,"correctAnswer":3,"difficulty":2,"active":true,"deleted":false,"language":"DE"
,"key":"DE_QZ"
,"cat":"Die Bundesliga"
,"qid":1381,"qstempel":1390138058267,"model":"QUESTION"}]
抛出这个异常,我完全不知道为什么???
java.lang.ClassNotFoundException: Didn't find class "java.beans.PropertyDescriptor" on path: DexPathList[[zip file "/data/app/bc.qz.client.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/bc.qz.client.android-2, /system/lib]]
谁能给我一些建议,为什么会发生这种情况?
提前致谢
斯特凡
最佳答案
java.lang.ClassNotFoundException: Didn't find class "java.beans.PropertyDescriptor" on path: DexPathList[[zip file "/data/app/bc.qz.client.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/bc.qz.client.android-2, /system/lib]]
某些东西具有依赖关系,该依赖关系未加载到一个代码路径中,而是加载到另一个代码路径中。 Android API 仅提供 Java 6 API 的子集:
PropertyDescriptor
。如果您自己的代码不使用此类型,那么您的库之一可能需要它。
关于java - BaseDexClassLoader 中的 JSONSerializer.toJSON ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21218197/
还是两者兼而有之? 最佳答案 因为扩展Object是不好的做法。 关于javascript - 为什么 MongoDB 不扩展对象以能够使用 a.tojson() 但仍然需要 tojson(a)?,我
我在另一个答案中看到,为了包含虚拟字段,您必须执行类似 https://groups.google.com/forum/?fromgroups#!topic/mongoose-orm/HjrPAP_W
我正在尝试使用 Gson 的 toJson API 将我的对象转换为 JSON 字符串。当我遇到支持相同的 2 个不同的 API 时。 As per Docs - public String toJs
我是knockout js的新手,我想将knockout.js与asp.net表单应用程序一起使用。我想使用 ajax 调用更新实体,如下所示 // Update product details
我是 JSON 的新手,因此我不确定 $.toJSON(params) 是什么意思。 请解释这是做什么的。 最佳答案 可能是这个jQuery plugin var myObj = {}; myObj.
让我们举个例子。我有一个 pojo 类,如下所示。 public class MyRecord{ private String name; private String id;
我有这样的代码: var test = new Date(2019, 03, 15, 13, 15, 0); console.log(test); //outputs Mon Apr 15 2019
我不确定为什么 this.model 在我的主干 View 中未定义。 这是我的脚本: var TheModel = Backbone.Model.extend({ defaults: {
我编写的组件将带有\n 换行符的文本转换为 html 段落 文本.js const Text = props => (( { props.paragraph.split('\n').ma
我需要从 JSON 响应中删除某些字段。为此,我使用了 toJSON() 方法。这是我的模态方法的代码。 User.methods.toJSON = function () { l
我在 asp.net mvc 页面上使用 knockoutjs。我正在使用 ajax 通过调用 ko.toJSON(viewModel) 将表单保存回服务器。然后使用 jQuery 将结果发布回服务器
我正在尝试使用 jQuery 和 Ajax,并且使用此方法。但我收到错误 $.toJSON is not a function in my firebug 。哪里有问题?我使用 jquery 1.3.
第一 quote来自 Redux 文档: It is highly recommended that you only put plain serializable objects,arrays, a
我创建了一个 .NET core 2.2 webapi,并使用 swagger/nswag 为我的 React/typescript 应用程序生成 API。当我尝试设置一个新对象时,我得到一个 ts(
例如,我位于澳大利亚,而 new Date() 为我提供澳大利亚的当前日期和时间2016 年 8 月 26 日星期五 09:16:16 GMT+1000(澳大利亚东部标准时间),如果我写 new Da
listData.forEach(function (row, index) { console.log(row); --> output JSON format { _id: 5
我对 knockout 计算的可观察值和 toJSON 函数有疑问。我创建了一个Fiddle Example 。在此示例中,我有一个模型: function VM() { this.Name =
我正在使用 knockout 映射插件从我的服务器映射对象。 我想重新发送这个对象,因此,我最终需要将这个对象转换为字符串。我在计算函数中使用了 knockout 函数 ko.toJSON,以便隐藏字
我正在尝试获取一些数据并使用 Backbone 显示它,但运气不佳 - 我没有收到任何错误,只是没有渲染(我使用 todos 示例作为指导构建了这个非常简单的应用程序) index.html:
我有一个 javascript 对象,如下所示: var Person = function() { var _name = ""; this.Age = 0; Object.
我是一名优秀的程序员,十分优秀!