我们可以使用 Linq 从 java 中的集合对象中获取值吗?
现在我正在黑莓上工作,我将一些 JSON 数组解析为字符串,然后将其转换为哈希表,就像这样
这是我的 JSON 字符串
[
{
"StdID":"A1",
"RollNo":"23",
"Class":"First"
},
{
"StdID":"A2",
"RollNo":"13",
"Class":"First"
},
{
"StdID":"A3",
"RollNo":"53",
"Class":"Second"
},
{
"StdID":"A4",
"RollNo":"33",
"Class":"Third"
},
]
,我将其解析为哈希表,
Hashtable t1=new Hashtable();
t1.put("StdID","A1");
t1.put("RollNo","23");
t1.put("Class","First");
Hashtable t2=new Hashtable();
t2.put("StdID","A2");
t2.put("RollNo","13");
t2.put("Class","First");
Hashtable t3=new Hashtable();
t3.put("StdID","A3");
t3.put("RollNo","53");
t3.put("Class","Second");
Hashtable t4=new Hashtable();
t4.put("StdID","A4");
t4.put("RollNo","33");
t4.put("Class","Third");
Hashtable main=new Hashtable ();
main.put(new Integer(1), t1);
main.put(new Integer(2), t2);
main.put(new Integer(3), t3);
main.put(new Integer(4), t4);
那么我/我如何检索该值
选择拥有一流课程的学生
所以有人可以帮助我吗? 这可以通过 LINQ 实现吗?
now a days i am working on blackberry within that i parse some JSON Array into String and from that i convert it into Hashtable like this
this is my JSON string
[
{
"StdID":"A1",
"RollNo":"23",
"Class":"First"
},
{
"StdID":"A2",
"RollNo":"13",
"Class":"First"
},
{
"StdID":"A3",
"RollNo":"53",
"Class":"Second"
},
{
"StdID":"A4",
"RollNo":"33",
"Class":"Third"
},
]
and i parse this into hashtable as
Hashtable t1=new Hashtable();
t1.put("StdID","A1");
t1.put("RollNo","23");
t1.put("Class","First");
Hashtable t2=new Hashtable();
t2.put("StdID","A2");
t2.put("RollNo","13");
t2.put("Class","First");
Hashtable t3=new Hashtable();
t3.put("StdID","A3");
t3.put("RollNo","53");
t3.put("Class","Second");
Hashtable t4=new Hashtable();
t4.put("StdID","A4");
t4.put("RollNo","33");
t4.put("Class","Third");
Hashtable main=new Hashtable ();
main.put(new Integer(1), t1);
main.put(new Integer(2), t2);
main.put(new Integer(3), t3);
main.put(new Integer(4), t4);
So can i/ how can i retrieve the value as
select students which have First class
so any one can help me?
is this possible by LINQ ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不。 LINQ 是 .NET 的一部分,而不是 Java 的一部分。
另请参阅
No. LINQ is part of .NET, not Java.
See also
嗯……是的!但是你需要这个库来处理 Java LINQ 的东西: //github.com/nicholas22/jpropel-light
如何做到这一点:
Uhm... yes! But you need this library for Java LINQ stuff: //github.com/nicholas22/jpropel-light
How to do it:
否 linq 适用于.NET 3.5 或更高版本,不适用于JAVA
No linq is for .NET 3.5 or greater not for JAVA
正如所有人所说,Java 没有 LINQ,因为这只是 .NET 技术。
但您可以使用提供类似功能的 API,例如 quaere
顺便说一句。其他人也问了类似的问题,请检查这个。
As all are saying there is no LINQ for Java as this is only .NET technology.
But you can use APIs which offer similar functionality, e.g. quaere
BTW. someonw else also asked a similar question, please check this out.