本文整理汇总了Java中org.apache.wink.json4j.JSONObject.getJSONArray方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getJSONArray方法的具体用法?Java JSONObject.getJSONArray怎么用?Java JSONObject.getJSONArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wink.json4j.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getJSONArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DataManagerImpl
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public DataManagerImpl(JSONObject settings) {
this.settings = settings;
if (this.settings == null) {
return;
}
try {
JSONArray array = settings.getJSONArray("configurations");
if (array == null) {
return;
}
for (int i = 0; i < array.length(); i++) {
JSONObject config = array.getJSONObject(i);
uuidSiteMap.put(config.getString("uuid"), config.getString("site_id"));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
示例3: toLocalizationInput
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
private static LocalizationInput toLocalizationInput(JSONArray locations) throws JSONException {
LocalizationInput locInput = new LocalizationInput();
List<Beacon> beacons = new ArrayList<Beacon>();
List<SensorData> sensors = new ArrayList<SensorData>();
for (int beaconIndex = 0; beaconIndex < locations.size(); beaconIndex++) {
JSONObject beaconInfo = locations.getJSONObject(beaconIndex);
if (beaconInfo.has("uuid") && beaconInfo.has("data")) {
String uuid = beaconInfo.getString("uuid");
locInput.setUuid(uuid);
JSONArray dataArray = beaconInfo.getJSONArray("data");
for (int dataIndex = 0; dataIndex < dataArray.size(); dataIndex++) {
JSONObject beaconData = dataArray.getJSONObject(dataIndex);
if (beaconData.has("major") && beaconData.has("minor") && beaconData.has("rssi")) {
beacons.add(new Beacon(beaconData.getInt("major"), beaconData.getInt("minor"), (float) beaconData.getDouble("rssi")));
}
}
}
if (beaconInfo.has("sensorCSV")) {
String csv = beaconInfo.getString("sensorCSV");
if(csv.equals("") || csv==null){
System.out.println("sensorCSV is not contained in input JSON.");
}else{
for(String line: csv.split("\n")) {
sensors.add(DataUtils.parseSensorData(line));
}
}
}
}
locInput.setBeacons(beacons);
locInput.setSensorDataList(sensors);
return locInput;
}
示例4: fromJSON
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public void fromJSON(JSONObject jobj){
try {
JSONArray jsonInvKyDY = jobj.getJSONArray("invKyDY");
invKyDY = JSONUtils.array2DFromJSONArray(jsonInvKyDY);
} catch (JSONException e) {
e.printStackTrace();
}
}
示例5: parseFeatures
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
static JSONArray parseFeatures(JSONObject json){
try{
String type = json.getString("type");
if(type.equals("FeatureCollection")){
JSONArray features = json.getJSONArray("features");
return features;
}
}catch(JSONException e){
e.printStackTrace();
}
return null;
}
示例6: 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();
}
}
示例7: 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;
}
示例8: 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;
}
示例9: readWalkLocations
import org.apache.wink.json4j.JSONObject; //导入方法依赖的package包/类
public static List<Location> readWalkLocations(InputStream is){
int z = 0;
List<Location> locs = 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("walk")){
double height = Double.parseDouble(properties.getString("height"));
int repeat = Integer.parseInt(properties.getString("repeat"));
JSONArray coordinates = geometry.getJSONArray("coordinates");
Iterator<JSONArray> iterCoords = coordinates.iterator();
while(iterCoords.hasNext()){
JSONArray coord = iterCoords.next();
double x = coord.getDouble(0);
double y = coord.getDouble(1);
Location loc = new Location(x, y, z);
loc.setH((float) height);
for(int t=0; t<repeat; t++){
locs.add(loc);
}
}
}
}
}
} catch (NullPointerException | JSONException e) {
e.printStackTrace();
}
return locs;
}