java类
public class Feature {
public Geometry getGeometry() {
return geometry;
}
public void setGeometry(Geometry geometry) {
this.geometry = geometry;
}
public Hashtable<String, Object> getAttributes() {
return attributes;
}
public void setAttributes(Hashtable<String, Object> attributes) {
this.attributes = attributes;
}
private Geometry geometry;
private Hashtable<String, Object> attributes;
}
其中的Geometry是个父类,没有属性,子类包括Point(double x,y),MultiPoint(ArrayList<ArrayList<Double>>),Path/Ring(ArrayList<ArrayList<ArrayList<Double>>>)等。
括号里的是属性,get和set就省略了。json字符串例子为:
{
"geometry" : {"x" : -118.15, "y" : 33.80},
"attributes" : {
"OWNER" : "Joe Smith",
"VALUE" : 94820.37,
"APPROVED" : true,
"LASTUPDATE" : 1227663551096
}
}或者
{
"geometry" :
{
"paths" :
[
[
[-95.9899452281111, 38.1345878074741],
[-95.9898896947778, 38.1344644074744],
[-95.9899164947778, 38.1343866074744]
]
]
},"attributes" : {
"objectid" : 1,
"fdate" : 932428800000,
...
}
}问题是怎么用jackson转换json字符串为Feature,并保证json的信息都存储进去。普通的ObjectMapper.readValue(String,Class)是不行了吧,用JsonParser又太麻烦,我感觉答案应该就在filter和注解上,但不熟悉,求大神指点。jsonjacksonfilter
public class Feature {
public Geometry getGeometry() {
return geometry;
}
public void setGeometry(Geometry geometry) {
this.geometry = geometry;
}
public Hashtable<String, Object> getAttributes() {
return attributes;
}
public void setAttributes(Hashtable<String, Object> attributes) {
this.attributes = attributes;
}
private Geometry geometry;
private Hashtable<String, Object> attributes;
}
其中的Geometry是个父类,没有属性,子类包括Point(double x,y),MultiPoint(ArrayList<ArrayList<Double>>),Path/Ring(ArrayList<ArrayList<ArrayList<Double>>>)等。
括号里的是属性,get和set就省略了。json字符串例子为:
{
"geometry" : {"x" : -118.15, "y" : 33.80},
"attributes" : {
"OWNER" : "Joe Smith",
"VALUE" : 94820.37,
"APPROVED" : true,
"LASTUPDATE" : 1227663551096
}
}或者
{
"geometry" :
{
"paths" :
[
[
[-95.9899452281111, 38.1345878074741],
[-95.9898896947778, 38.1344644074744],
[-95.9899164947778, 38.1343866074744]
]
]
},"attributes" : {
"objectid" : 1,
"fdate" : 932428800000,
...
}
}问题是怎么用jackson转换json字符串为Feature,并保证json的信息都存储进去。普通的ObjectMapper.readValue(String,Class)是不行了吧,用JsonParser又太麻烦,我感觉答案应该就在filter和注解上,但不熟悉,求大神指点。jsonjacksonfilter
解决方案 »
- javamail 求高手
- spring的aop应用出问题
- 用hql或者Criteria查询距今6个月没有下订单的客户
- jsp+struts保险系统
- jsf中的一个问题
- 急求XML节点修改问题!!!
- webshpere,structs,spring,Hiber,JSF,EJB等问题
- 正在开发一个struts架构的软件,其中牵涉到大量的数据库访问(搜索功能等),因初学,请有经验的大哥提醒一下应该注意的问题(不限于数据
- 什么是Hibernate 在学习它之前应该掌握什么呢
- java.awt.print 如何实现套打阿?
- Servlet下载xml文件,不弹窗了
- spring 整合 hibernate 使用泛型的异常
Son son=new Father();可以
但是
Father father=new Son();可以么?