mirror of
https://github.com/alibaba/fastjson.git
synced 2026-10-29 06:06:50 +08:00
add testcase
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -13,15 +11,7 @@ public class VansAnimation implements Serializable{
|
||||
public String fps;
|
||||
public String name;
|
||||
public ArrayList<String> tracks;
|
||||
public VansAnimation(JSONObject object){
|
||||
if(object == null){
|
||||
return;
|
||||
}
|
||||
fps = ModelUtils.nullToEmpty(object.getString("fps"));
|
||||
name = ModelUtils.nullToEmpty(object.getString("name"));
|
||||
fps = ModelUtils.nullToEmpty(object.getString("fps"));
|
||||
tracks = ModelUtils.convertJSONArray(object.getJSONArray("tracks"));
|
||||
}
|
||||
|
||||
public VansAnimation(){
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -13,7 +9,7 @@ import java.util.List;
|
||||
*/
|
||||
public class VansData implements Serializable{
|
||||
|
||||
public ArrayList<Integer> textures;
|
||||
public int[] textures;
|
||||
public ArrayList<String> images;
|
||||
public VansObject object;
|
||||
public VansMetaData metadata;
|
||||
@@ -21,29 +17,4 @@ public class VansData implements Serializable{
|
||||
public ArrayList<VansAnimation> animations;
|
||||
public Object materials;
|
||||
|
||||
public VansData(JSONObject jsonObject){
|
||||
if(jsonObject == null){
|
||||
return;
|
||||
}
|
||||
textures = ModelUtils.convertJSONArray(jsonObject.getJSONArray("textures"));
|
||||
images = ModelUtils.convertJSONArray(jsonObject.getJSONArray("images"));
|
||||
animations = ModelUtils.convertJSONArray(jsonObject.getJSONArray("animations"), new ModelUtils.EntryConverter<VansAnimation>() {
|
||||
@Override
|
||||
public VansAnimation convert(Object obj) {
|
||||
return new VansAnimation((JSONObject) obj);
|
||||
}
|
||||
});
|
||||
object = new VansObject(jsonObject.getJSONObject("object"));
|
||||
metadata = new VansMetaData(jsonObject.getJSONObject("metadata"));
|
||||
geometries = ModelUtils.convertJSONArray(jsonObject.getJSONArray("geometries"), new ModelUtils.EntryConverter<VansGeometry>() {
|
||||
@Override
|
||||
public VansGeometry convert(Object obj) {
|
||||
return new VansGeometry((JSONObject) obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
public VansData(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -13,14 +10,6 @@ public class VansGeometry implements Serializable{
|
||||
public String type;
|
||||
public VansGeometryData data;
|
||||
|
||||
public VansGeometry(JSONObject object){
|
||||
if(object == null){
|
||||
return;
|
||||
}
|
||||
uuid = ModelUtils.nullToEmpty(object.getString("uuid"));
|
||||
type = ModelUtils.nullToEmpty(object.getString("type"));
|
||||
data = new VansGeometryData(object.getJSONObject("data"));
|
||||
}
|
||||
public VansGeometry(){
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +1,23 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by xiaolin_kxl on 16/12/28.
|
||||
*/
|
||||
|
||||
@JSONType(orders = {"uvs","metadata","normals","name","faces","vertices"})
|
||||
public class VansGeometryData implements Serializable{
|
||||
public ArrayList<ArrayList<Float>> uvs;
|
||||
public float[][] uvs;
|
||||
|
||||
@JSONField(name = "metadata")
|
||||
public VansGeometryDataMetaData metaData;
|
||||
public ArrayList<Float> normals;
|
||||
|
||||
public float[] normals;
|
||||
public String name;
|
||||
public ArrayList<Integer> faces;
|
||||
public ArrayList<Float> vertices;
|
||||
public VansGeometryData(JSONObject object){
|
||||
if(object == null){
|
||||
return;
|
||||
}
|
||||
metaData = new VansGeometryDataMetaData(object.getJSONObject("metadata"));
|
||||
name = ModelUtils.nullToEmpty(object.getString("name"));
|
||||
normals = ModelUtils.convertFloatJSONArray(object.getJSONArray("normals"));
|
||||
faces = ModelUtils.convertIntegerJSONArray(object.getJSONArray("faces"));
|
||||
vertices = ModelUtils.convertFloatJSONArray(object.getJSONArray("vertices"));
|
||||
JSONArray array = object.getJSONArray("uvs");
|
||||
if(array == null && array.size() == 0){
|
||||
return;
|
||||
}
|
||||
uvs = new ArrayList<ArrayList<Float>>();
|
||||
int length = array.size();
|
||||
for(int i = 0; i < length; i++){
|
||||
JSONArray array1 = array.getJSONArray(i);
|
||||
if(array1 == null && array1.size() == 0){
|
||||
continue;
|
||||
}
|
||||
uvs.add(ModelUtils.convertFloatJSONArray(array1));
|
||||
}
|
||||
}
|
||||
public int[] faces;
|
||||
public float[] vertices;
|
||||
|
||||
public VansGeometryData(){
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -17,18 +14,6 @@ public class VansGeometryDataMetaData implements Serializable {
|
||||
public int vertices;
|
||||
public String generator;
|
||||
|
||||
public VansGeometryDataMetaData(JSONObject object) {
|
||||
if (object == null) {
|
||||
return;
|
||||
}
|
||||
generator = ModelUtils.nullToEmpty(object.getString("generator"));
|
||||
version = object.getIntValue("version");
|
||||
uvs = object.getIntValue("uvs");
|
||||
normals = object.getIntValue("normals");
|
||||
faces = object.getIntValue("faces");
|
||||
vertices = object.getIntValue("vertices");
|
||||
}
|
||||
|
||||
public VansGeometryDataMetaData() {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@@ -12,14 +9,6 @@ public class VansMetaData implements Serializable{
|
||||
public String version;
|
||||
public String type;
|
||||
public String generator;
|
||||
public VansMetaData(JSONObject object){
|
||||
if(object == null){
|
||||
return;
|
||||
}
|
||||
version = ModelUtils.nullToEmpty(object.getString("version"));
|
||||
type = ModelUtils.nullToEmpty(object.getString("type"));
|
||||
generator = ModelUtils.nullToEmpty(object.getString("generator"));
|
||||
}
|
||||
public VansMetaData(){
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -9,26 +8,10 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Created by xiaolin_kxl on 17/1/5.
|
||||
*/
|
||||
@JSONType(orders = {"uuid","type","matrix","children"})
|
||||
public class VansObject implements Serializable {
|
||||
public String uuid;
|
||||
public String type;
|
||||
// public ArrayList<Float> matrix;
|
||||
public ArrayList<VansObjectChildren> children;
|
||||
public VansObject(JSONObject object){
|
||||
if(object == null){
|
||||
return;
|
||||
}
|
||||
uuid = ModelUtils.nullToEmpty(object.getString("uuid"));
|
||||
type = ModelUtils.nullToEmpty(object.getString("type"));
|
||||
children = ModelUtils.convertJSONArray(object.getJSONArray("children"), new ModelUtils.EntryConverter<VansObjectChildren>() {
|
||||
@Override
|
||||
public VansObjectChildren convert(Object obj) {
|
||||
return new VansObjectChildren((JSONObject) obj);
|
||||
}
|
||||
});
|
||||
// matrix = ModelUtils.convertJSONArray(object.getJSONArray("matrix"));
|
||||
}
|
||||
public VansObject(){
|
||||
|
||||
}
|
||||
public float[] matrix;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.vans.test.vansdemo.vo;
|
||||
package com.alibaba.json.test.vans;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.vans.test.vansdemo.util.ModelUtils;
|
||||
import com.alibaba.fastjson.annotation.JSONType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -9,6 +8,7 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Created by xiaolin_kxl on 17/1/5.
|
||||
*/
|
||||
@JSONType(orders = {"name","uuid","matrix","visible","type","children","castShadow","receiveShadow","geometry"})
|
||||
public class VansObjectChildren implements Serializable{
|
||||
public String name;
|
||||
public String uuid;
|
||||
@@ -17,28 +17,6 @@ public class VansObjectChildren implements Serializable{
|
||||
public String geometry;
|
||||
public boolean castShadow;
|
||||
public boolean receiveShadow;
|
||||
// public ArrayList<Float> matrix;
|
||||
public float[] matrix;
|
||||
public ArrayList<VansObjectChildren> children;
|
||||
public VansObjectChildren(JSONObject object){
|
||||
if(object == null){
|
||||
return;
|
||||
}
|
||||
uuid = ModelUtils.nullToEmpty(object.getString("uuid"));
|
||||
type = ModelUtils.nullToEmpty(object.getString("type"));
|
||||
name = ModelUtils.nullToEmpty(object.getString("name"));
|
||||
geometry = ModelUtils.nullToEmpty(object.getString("geometry"));
|
||||
visible = object.getBooleanValue("visible");
|
||||
castShadow = object.getBooleanValue("castShadow");
|
||||
receiveShadow = object.getBooleanValue("receiveShadow");
|
||||
children = ModelUtils.convertJSONArray(object.getJSONArray("children"), new ModelUtils.EntryConverter<VansObjectChildren>() {
|
||||
@Override
|
||||
public VansObjectChildren convert(Object obj) {
|
||||
return new VansObjectChildren((JSONObject) obj);
|
||||
}
|
||||
});
|
||||
// matrix = ModelUtils.convertJSONArray(object.getJSONArray("matrix"));
|
||||
}
|
||||
public VansObjectChildren(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user