Example usage for org.json.simple JSONObject toJSONString

List of usage examples for org.json.simple JSONObject toJSONString

Introduction

In this page you can find the example usage for org.json.simple JSONObject toJSONString.

Prototype

public String toJSONString() 

Source Link

Usage

From source file:com.garethahealy.jolokiajvmhawkular.core.metrics.HawkularMetricsService.java

public void run() {
    LOG.info("Running...");

    JavaType mapClazzKeyType = objectMapper.getTypeFactory().constructType(String.class);
    JavaType mapClazzValueType = objectMapper.getTypeFactory().constructType(Object.class);
    JavaType mapClazzType = objectMapper.getTypeFactory().constructMapType(LinkedHashMap.class, mapClazzKeyType,
            mapClazzValueType);/*from www  .j  a  v  a 2 s .co m*/

    for (Collector current : collectors) {
        JSONObject response = handleRequest(current.generate());

        try {
            Map<String, Object> data = objectMapper.readValue(response.toJSONString(), mapClazzType);
            current.process(client, data);
        } catch (IOException e) {
            LOG.error("{}", e);
        }
    }
}

From source file:com.github.lgi2p.obirs.utils.IndexerJSON.java

public void index(String indexFilePath) throws SLIB_Ex_Critic {

    items = new ArrayList();
    metadata = new HashMap();

    logger.info("Loading items");

    JSONParser parser = new JSONParser();
    BufferedReader br = null;//from  w  w w.  j  a  va2s . c o m
    String line = null;
    try {
        br = new BufferedReader(new FileReader(indexFilePath));

        while ((line = br.readLine()) != null) {
            JSONObject jsonObject = (JSONObject) parser.parse(line);
            indexItem(jsonObject.toJSONString());
        }
        br.close();
    } catch (Exception e) {
        e.printStackTrace();
        throw new SLIB_Ex_Critic("error processing line: " + line + "\n" + e.getMessage());
    }
    logger.info("indexation done (" + items.size() + " items)");
}

From source file:com.aerothai.database.accessory.AccessorysResource.java

/**
 * Retrieves representation of an instance of com.aerothai.AccessorysResource
 * @return an instance of java.lang.String
 */// ww w .j a  v a  2s  . co m
@GET
// Produces JSON as response
@Produces("application/json")
//@Produces("application/xml")
public String listAccessory(@QueryParam("idunit") int idunit, @QueryParam("column") String column,
        @QueryParam("value") String value) {
    String response = null;
    String opt = null;
    AccessoryService accessoryService = new AccessoryService();
    System.out.println("List Accessory All");
    if (accessoryService.isNotNull(column) && accessoryService.isNotNull(value)) {
        //System.out.println("column = :"+column+" v =:"+value);
        opt = " " + column + " = '" + value + "'";
    }

    try {
        JSONObject accessoryData = null;

        accessoryData = accessoryService.GetAccessoryAll(idunit, opt);

        response = accessoryData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}

From source file:com.aerothai.database.sparepart.SparepartsResource.java

/**
 * Retrieves representation of an instance of com.aerothai.SparepartsResource
 * @return an instance of java.lang.String
 *///  ww  w  .  j  a  v a 2s. c om
@GET
// Produces JSON as response
@Produces("application/json")
//@Produces("application/xml")
public String listSparepart(@QueryParam("idunit") int idunit, @QueryParam("column") String column,
        @QueryParam("value") String value) {
    String response = null;
    String opt = null;
    SparepartService sparepartService = new SparepartService();
    System.out.println("List Sparepart All");
    if (sparepartService.isNotNull(column) && sparepartService.isNotNull(value)) {
        //System.out.println("column = :"+column+" v =:"+value);
        opt = " " + column + " = '" + value + "'";
    }

    try {
        JSONObject sparepartData = null;

        sparepartData = sparepartService.GetSparepartAll(idunit, opt);

        response = sparepartData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}

From source file:minor.eft.ETFQuote.java

@Override
public String execute() {

    System.out.println("Ticker in Commodity Quote: " + getCticker());
    System.out.println("Checking");
    //List<CommodityDetails> sd2 = cdf.getCommodityData(getCticker());
    //System.out.println("Size of return Value: "+sd2.size());
    /*/*from ww  w.j  a va 2  s.  c o m*/
    for(CommodityDetails cd : sd2){
    cdf.create(cd);
    }*/
    JSONObject quote = eTFDetailsFacade.getETFData(getCticker());
    System.out.println("Array List: " + quote.toJSONString());
    //System.out.println("CDF String: "+cdf.toString());
    //System.out.println("Checking again");

    Set<String> st = quote.keySet();
    try {
        for (String s : st) {
            if (quote.get(s) == null) {
                System.out.println("IN IF");
                //quote.remove(s);
                quote.put(s, "NA");
            }
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    ETFDetails cd = new ETFDetails(quote);
    System.out.println(cd.getPERatio());
    System.out.println(cd.getEBITDA());
    System.out.println(cd.getPreviousClose());
    System.out.println(cd.getDaysHigh());
    System.out.println(cd.getVolume());
    setSd(cd);
    //setSd(sd.add(cd));
    if (true) {
        return "success";
    } else {
        System.out.println("Checking again again");
        return "error";
    }
}

From source file:com.aerothai.database.device.DevicesResource.java

/**
 * Retrieves representation of an instance of com.aerothai.DevicesResource
 * @return an instance of java.lang.String
 *///ww  w . j a v a  2  s  .  c om
@GET
// Produces JSON as response
@Produces("application/json")
//@Produces("application/xml")
public String listDevice(@QueryParam("idunit") int idunit, @QueryParam("column") String column,
        @QueryParam("value") String value) {
    String response = null;
    String opt = null;
    DeviceService deviceService = new DeviceService();
    System.out.println("List Device All");
    if (deviceService.isNotNull(column) && deviceService.isNotNull(value)) {
        //System.out.println("column = :"+column+" v =:"+value);
        opt = " " + column + " = '" + value + "'";
    }

    try {
        JSONObject deviceData = null;

        deviceData = deviceService.GetDeviceAll(idunit, opt);

        response = deviceData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}

From source file:com.aerothai.database.radiosignal.RadiosignalsResource.java

/**
 * Retrieves representation of an instance of com.aerothai.RadiosignalsResource
 * @return an instance of java.lang.String
 *//*from w  ww . j a  v  a2 s .com*/
@GET
// Produces JSON as response
@Produces("application/json")
//@Produces("application/xml")
public String listRadiosignal(@QueryParam("column") String column, @QueryParam("value") String value) {
    String response = null;
    String opt = null;
    RadiosignalService radiosignalService = new RadiosignalService();
    System.out.println("List Radiosignal All");
    if (radiosignalService.isNotNull(column) && radiosignalService.isNotNull(value)) {
        //System.out.println("column = :"+column+" v =:"+value);
        opt = " " + column + " = '" + value + "'";
    }

    try {
        JSONObject radiosignalData = null;

        radiosignalData = radiosignalService.GetRadiosignalAll(opt);

        response = radiosignalData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}

From source file:com.aerothai.database.servicemethod.ServicemethodsResource.java

/**
 * Retrieves representation of an instance of com.aerothai.ServicemethodsResource
 * @return an instance of java.lang.String
 *///from  w  w  w  .j av  a  2s  .  c o  m
@GET
// Produces JSON as response
@Produces("application/json")
//@Produces("application/xml")
public String listServicemethod(@QueryParam("column") String column, @QueryParam("value") String value) {
    String response = null;
    String opt = null;
    ServicemethodService servicemethodService = new ServicemethodService();
    System.out.println("List Servicemethod All");
    if (servicemethodService.isNotNull(column) && servicemethodService.isNotNull(value)) {
        //System.out.println("column = :"+column+" v =:"+value);
        opt = " " + column + " = '" + value + "'";
    }

    try {
        JSONObject servicemethodData = null;

        servicemethodData = servicemethodService.GetServicemethodAll(opt);

        response = servicemethodData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}

From source file:at.uni_salzburg.cs.ckgroup.cscpp.mapper.RegData.java

public RegData(JSONObject obj) {
    LOG.info("new RegData(): obj=" + obj.toJSONString());
    engineUri = (String) obj.get("engUri");
    Object ce = obj.get("centralEngine");
    centralEngine = ce == null ? false : ((Boolean) ce).booleanValue();
    pilotUri = (String) obj.get("pilotUri");
    pilotConfig = new HashMap<String, String>();
    pilotConfig.put("pilotName", (String) obj.get("pilotName"));

    Object array = obj.get("sensors");
    if (array == null) {
        sensors = null;/* w  ww  .ja  v  a 2s . c o m*/
    } else {
        sensors = new HashSet<String>();
        for (Object entry : (JSONArray) array) {
            sensors.add((String) entry);
        }
    }

    array = (JSONArray) obj.get("waypoints");
    if (array == null) {
        wayPoints = null;
    } else {
        wayPoints = new ArrayList<IWayPoint>();
        for (Object entry : (JSONArray) array) {
            WayPoint wayPoint = new WayPoint((JSONObject) entry);
            wayPoints.add(wayPoint);
        }
    }

    assignedZone = null;
}

From source file:com.aerothai.database.jobevaluate.JobevaluatesResource.java

/**
 * Retrieves representation of an instance of com.aerothai.JobevaluatesResource
 * @return an instance of java.lang.String
 *///from w  w  w .  j  a  v a 2 s.c o m
@GET
// Produces JSON as response
@Produces("application/json")
//@Produces("application/xml")
public String listJobevaluate(@QueryParam("idjob") int idjob, @QueryParam("column") String column,
        @QueryParam("value") String value) {
    String response = null;
    String opt = null;
    JobevaluateService jobevaluateService = new JobevaluateService();
    System.out.println("List Jobevaluate All");
    if (jobevaluateService.isNotNull(column) && jobevaluateService.isNotNull(value)) {
        //System.out.println("column = :"+column+" v =:"+value);
        opt = " " + column + " = '" + value + "'";
    }

    try {
        JSONObject jobevaluateData = null;

        jobevaluateData = jobevaluateService.GetJobevaluateAll(idjob, opt);

        response = jobevaluateData.toJSONString();
    } catch (Exception e) {
        System.out.println("error");
    }

    return response;
}