本文整理汇总了Java中org.apache.wink.json4j.JSONObject.getJSONObject方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getJSONObject方法的具体用法?Java JSONObject.getJSONObject怎么用?Java JSONObject.getJSONObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wink.json4j.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getJSONObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: settingFromJSON
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public void settingFromJSON(JSONObject json){
super.settingFromJSON(json);
try {
JSONObject ldplParams = json.getJSONObject(LDPLParameters);
//LDPLParameters
if(ldplParams.containsKey("lambdas")){
JSONArray jarray = ldplParams.getJSONArray("lambdas");
double[] lambdas = JSONUtils.array1DfromJSONArray(jarray);
System.out.println("lambdas = "+jarray.toString());
gpLDPL.setStabilizeParameter(lambdas);
}else{
System.out.println("The key for [lambdas] was not found.");
optMultiHP = true;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
示例2: settingFromJSON
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
@Override
public void settingFromJSON(JSONObject json){
paramsJSON = json;
try {
double sigma = json.getDouble("sigma");
setSigma(sigma);
// Set parameters for sensor data
JSONObject oriParams = json.getJSONObject(SensorData.ORIENTATION_METER);
ori = OrientationMeterFactory.create(oriParams);
JSONObject pedoParams = json.getJSONObject(SensorData.PEDOMETER);
pedo = PedometerFactory.create(pedoParams);
// PoseSetting
JSONObject poseSettingJSON = json.getJSONObject(PoseSetting.SIMPLE_NAME);
this.poseSetting = PoseSetting.createFromJSON(poseSettingJSON);
System.out.println("PoseData.setting : "+poseSetting.toString());
this.poseMotion = PoseMotion.create(poseSetting);
} catch (JSONException e) {
e.printStackTrace();
}
}
示例3: create
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static BeaconFilter create(JSONObject json){
BeaconFilter bf = null;
try{
String name = json.getString("name");
JSONObject params = json.getJSONObject("parameters");
for(BeaconFilter bfTemp: loader){
if(name.equals(bfTemp.getClass().getSimpleName())){
bf = bfTemp;
bf.settingFromJSON(params);
break;
}
}
if(bf==null){
System.err.println(name + " is not supported in "+BeaconFilterFactory.class.getSimpleName()+".");
}
}catch(JSONException e){
e.printStackTrace();
}
return bf;
}
示例4: create
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static SyntheticDataGenerator create(JSONObject json){
SyntheticDataGenerator gen = new SyntheticDataGenerator();
try{
JSONObject beaconJSON = json.getJSONObject("Beacon");
JSONObject motionJSON = json.getJSONObject("Motion");
gen.beaconGen = new SyntheticBeaconDataGenerator(beaconJSON);
gen.motionGen = new SyntheticMotionDataGenerator(motionJSON);
JSONObject randomJSON = json.getJSONObject("Random");
int seed = randomJSON==null ? 1234 : randomJSON.getInt("seed");
gen.beaconGen.setRandom(new Random(seed));
gen.motionGen.setRandom(new Random(seed));
}catch(JSONException e){
e.printStackTrace();
}
return gen;
}
示例5: loadMapData
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
static public MapData loadMapData(String projectPath, JSONObject formatJSON){
MapData mapData = null;
JSONObject mapFormatJSON = null;
try {
mapFormatJSON = formatJSON.getJSONObject("map");
} catch (JSONException e) {
e.printStackTrace();
}
for(MapDataReader mapReader: mapReaderLoader){
if(mapReader.hasReadMethod(mapFormatJSON)){
System.out.println("MapDataReader="+mapReader);
mapData = mapReader.read(projectPath, mapFormatJSON);
return mapData;
}
}
throw new RuntimeException("MapDataReader was not found. MapFormatJSON = "+mapFormatJSON);
}
示例6: create
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static LikelihoodModel create(JSONObject json){
LikelihoodModel likelihoodModel = null;
try {
if(json==null){
likelihoodModel = new NormalDist();
}
else if(json!=null){
String name = json.getString("name");
JSONObject paramsJSON = json.getJSONObject("parameters");
for(LikelihoodModel lmTemp: loader){
if(name.equals(lmTemp.getClass().getSimpleName())){
likelihoodModel = lmTemp;
likelihoodModel.settingFromJSON(paramsJSON);
System.out.println(likelihoodModel.toString() + " was created.");
break;
}
}
if(likelihoodModel==null){
System.err.println(name+ " is not supported in " + LikelihoodModelFactory.class.getSimpleName() + ".");
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return likelihoodModel;
}
示例7: create
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
@Override
public ObservationModel create(JSONObject json, ProjectData projData) {
ObservationModel model=null;
try{
String name = json.getString("name");
JSONObject paramsJSON = json.getJSONObject("parameters");
JSONObject sysJSON = paramsJSON.getJSONObject(SystemModel.class.getSimpleName());
SystemModel sysModel =ModelBuilderCore.buildSystemModel(sysJSON, projData);
JSONObject obsJSON = paramsJSON.getJSONObject(ObservationModel.class.getSimpleName());
ObservationModel obsModel = ModelBuilderCore.buildObservationModel(obsJSON, projData);
ParticleFilter pf = null;
if(name.equals(ParticleFilter.class.getSimpleName())){
pf = new ParticleFilter(sysModel, obsModel);
}else if(name.equals(ParticleFilterWithSensor.class.getSimpleName())){
pf = new ParticleFilterWithSensor(sysModel, obsModel);
}
pf.settingFromJSON(paramsJSON);
pf.train(projData.trainData().getSamples());
model = pf;
}catch(JSONException e){
e.printStackTrace();
}
return model;
}
示例8: create
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
@Override
public ObservationModel create(JSONObject json, ProjectData projData) {
ObservationModel model=null;
try{
String name = json.getString("name");
JSONObject paramsJSON = json.getJSONObject("parameters");
GaussianProcessLDPLMeanModel obsModel = null;
if(name.equals(GaussianProcessLDPLMeanModel.class.getSimpleName())){
obsModel = new GaussianProcessLDPLMeanModel();
}else if(name.equals(GaussianProcessLDPLMeanMultiModel.class.getSimpleName())){
obsModel = new GaussianProcessLDPLMeanMultiModel();
}
obsModel.settingFromJSON(paramsJSON);
List<BLEBeacon> bleBeacons = projData.mapData().getBLEBeacons();
BLEBeacon.reassignShortestIds(bleBeacons);
obsModel.setBLEBeacons(bleBeacons);
obsModel.train(projData.trainData().getSamples());
JSONObject trainedJSON = obsModel.toJSON();
json.put("parameters", trainedJSON);
model = obsModel;
}catch(JSONException e){
e.printStackTrace();
}
return model;
}
示例9: toJSON
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public JSONObject toJSON(){
JSONObject json = super.toJSON();
try {
JSONObject LDPLJSON = json.getJSONObject(LDPLParameters);
double[] lambdas = gpLDPL.getStabilizeParameter();
LDPLJSON.put("lambdas", new Double[]{lambdas[0],lambdas[1],lambdas[2],lambdas[3]});
} catch (JSONException e) {
e.printStackTrace();
}
return json;
}
示例10: settingFromJSON
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
@Override
public void settingFromJSON(JSONObject json){
paramsJSON = json;
try {
sigmaWalk = json.getDouble("sigmaWalk");
sigmaStay = json.getDouble("sigmaStay");
setSigma(sigmaWalk);
JSONObject pedoParams = json.getJSONObject(SensorData.PEDOMETER);
pedo = PedometerFactory.create(pedoParams);
} catch (JSONException e) {
e.printStackTrace();
}
}
示例11: settingFromJSON
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
@Override
public void settingFromJSON(JSONObject json){
paramsJSON = json;
try {
sigmaWalk = json.getDouble("sigmaWalk");
sigmaStay = json.getDouble("sigmaStay");
randomWalker.setSigma(sigmaWalk);
JSONObject pedoParams = json.getJSONObject(SensorData.PEDOMETER);
pedo = PedometerFactory.create(pedoParams);
} catch (JSONException e) {
e.printStackTrace();
}
}
示例12: loadInformation
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public ProjectData.Info loadInformation(JSONObject formatJSON){
ProjectData.Info projInfo = null;
if(formatJSON.has(INFORMATION)){
try {
JSONObject info = formatJSON.getJSONObject(INFORMATION);
projInfo = new ProjectData.Info(info);
System.out.println("information="+info.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
return projInfo;
}
示例13: settingFromJSON
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public void settingFromJSON(JSONObject json){
jsonParams = json;
try {
JSONObject ldplParams = json.getJSONObject(LDPLParameters);
JSONObject gpParams = json.getJSONObject(GPParameters);
JSONObject optJSON = json.getJSONObject(OPTIONS);
//LDPLParameters
double n = ldplParams.getDouble("n");
double A = ldplParams.getDouble("A");
double fa = ldplParams.getDouble("fa");
double fb = ldplParams.getDouble("fb");
if(ldplParams.containsKey(HDIFF)){
double hDiff = ldplParams.getDouble(HDIFF);
this.setParams(new double[]{n,A,fa,fb});
this.setHDiff(hDiff);
}
//GPParamters
JSONArray jarray = gpParams.getJSONArray("lengthes");
lengthes = JSONUtils.array1DfromJSONArray(jarray);
stdev = gpParams.getDouble("sigmaP");
sigmaN = gpParams.getDouble("sigmaN");
boolean useMask = (gpParams.getInt("useMask") == 1);
int optConstVar = gpParams.getInt("constVar");
gpLDPL.setUseMask(useMask);
gpLDPL.setOptConstVar(optConstVar);
// Options
doHyperParameterOptimize = optJSON.optBoolean("optimizeHyperParameters");
if(! doHyperParameterOptimize){
doHyperParameterOptimize = optJSON.optInt("optimizeHyperParameters")==1;
}
// Optional variables
if(gpParams.containsKey(ARRAYS)){
JSONObject jobjArrays = gpParams.getJSONObject(ARRAYS);
gpLDPL.fromJSON(jobjArrays);
}
if(json.containsKey(LIKELIHOOD_MODEL)){
JSONObject likelihoodJSON = json.getJSONObject(LIKELIHOOD_MODEL);
LikelihoodModel likelihoodModel = LikelihoodModelFactory.create(likelihoodJSON);
gpLDPL.setLikelihoodModel(likelihoodModel);
}else{
System.out.println("The key for ["+LIKELIHOOD_MODEL +"] was not found.");
}
if(json.containsKey(BEACON_FILTER)){
JSONObject bfJSON = json.getJSONObject(BEACON_FILTER);
BeaconFilter bf = BeaconFilterFactory.create(bfJSON);
beaconFilter = bf;
}else{
System.out.println("The key for ["+BEACON_FILTER +"] was not found.");
}
} catch (JSONException e) {
e.printStackTrace();
}
}
示例14: readMapBLEBeacons
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static List<BLEBeacon> readMapBLEBeacons(InputStream is){
int z = 0;
List<BLEBeacon> bleBeacons = new ArrayList<>();
try {
JSONObject json = (JSONObject) JSON.parse(is);
String type = json.getString("type");
if(type.equals("FeatureCollection")){
JSONArray features = json.getJSONArray("features");
Iterator<JSONObject> iter = features.iterator();
while(iter.hasNext()){
JSONObject feature = iter.next();
JSONObject properties = feature.getJSONObject("properties");
JSONObject geometry = feature.getJSONObject("geometry");
type = properties.getString("type");
if(type.equals("beacon")){
int major = Integer.parseInt(properties.getString("major"));
int minor = Integer.parseInt(properties.getString("minor"));
String uuid = properties.getString("uuid");
int outPower = Integer.parseInt(properties.getString("power"));
int interval = Integer.parseInt(properties.getString("interval"));
double x = geometry.getJSONArray("coordinates").getInt(0);
double y = geometry.getJSONArray("coordinates").getInt(1);
BLEBeacon bleBeacon = new BLEBeacon(minor, major, minor, x, y, z);
bleBeacon.setUuid(uuid);
bleBeacon.setOutputPower(outPower);
bleBeacons.add(bleBeacon);
}
}
}
} catch (NullPointerException | JSONException e) {
e.printStackTrace();
}
return bleBeacons;
}
示例15: readWalls
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static List<Wall> readWalls(InputStream is){
int z = 0;
List<Wall> walls = new ArrayList<>();
try {
JSONObject json = (JSONObject) JSON.parse(is);
String type = json.getString("type");
if(type.equals("FeatureCollection")){
JSONArray features = json.getJSONArray("features");
Iterator<JSONObject> iter = features.iterator();
while(iter.hasNext()){
JSONObject feature = iter.next();
JSONObject properties = feature.getJSONObject("properties");
JSONObject geometry = feature.getJSONObject("geometry");
type = properties.getString("type");
if(type.equals("wall")){
double height = Double.parseDouble(properties.getString("height"));
double attenuation = Double.parseDouble(properties.getString("decay"));
JSONArray coordsArray = geometry.getJSONArray("coordinates");
int npoints = coordsArray.size();
for(int i=0; i<npoints-1; i++){
JSONArray p0 = coordsArray.getJSONArray(i);
JSONArray p1 = coordsArray.getJSONArray(i+1);
Wall wall = new Wall.Builder(p0.getDouble(0), p0.getDouble(1), p1.getDouble(0), p1.getDouble(1))
.height(height)
.attenuation(attenuation)
.build();
walls.add(wall);
}
}
}
}
} catch (NullPointerException | JSONException e) {
e.printStackTrace();
}
return walls;
}