APISonar


com.github.ltsopensource.core.json.JSON.toJSONString

> com > github > ltsopensource > core > json > JSON > toJSONString
com APIs github APIs ltsopensource APIs core APIs json APIs JSON APIs toJSONString APIs

Example 1
public String getAsText() {
        Map<?, ?> value = (Map<?, ?>) getValue();

        if (value == null) {
            return "";
        }
        return JSON.toJSONString(value);
    }
Example 2
public void serialize(Object value, OutputStream out) throws IOException {
        String v = JSON.toJSONString(value);
        if (v != null) {
            out.write(v.getBytes("UTF-8"));
        }
    }
Example 3
public HttpCmdResponse execute(HttpCmdRequest request) throws Exception {

        Map<String, Object> jvmInfo = JVMCollector.getJVMInfo();

        HttpCmdResponse response = new HttpCmdResponse();
        response.setSuccess(true);
        response.setObj(JSON.toJSONString(jvmInfo));

        return response;
    }
Example 4
public void put(String key, Object value) throws FailStoreException {
        try {
            String valueString = JSON.toJSONString(value);
            @SuppressWarnings("unused")
			OperationStatus status = db.put(null, new DatabaseEntry(key.getBytes("UTF-8")),
                    new DatabaseEntry(valueString.getBytes("UTF-8")));
        } catch (Exception e) {
            throw new FailStoreException(e);
        }
    }
Example 5
public static void main(String[] args) throws IOException {
        TestProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(TestProperties.class);
        System.out.println(JSON.toJSONString(properties));

//        JSONFactory.setJSONAdapter("ltsjson");
//        System.out.println(JSON.parse("2321321", Integer.class));
    }
Example 6
public void put(String key, Object value) throws FailStoreException {
        String valueString = JSON.toJSONString(value);
        WriteOptions writeOpts = new WriteOptions();
        try {
            writeOpts.setSync(true);
            writeOpts.setDisableWAL(true);
            db.put(writeOpts, key.getBytes("UTF-8"), valueString.getBytes("UTF-8"));
        } catch (Exception e) {
            throw new FailStoreException(e);
        } finally {
            writeOpts.dispose();
        }
    }
Example 7
private void fix() {
        Set<String> nodeGroups = appContext.getTaskTrackerManager().getNodeGroups();
        if (CollectionUtils.isEmpty(nodeGroups)) {
            return;
        }
        for (String nodeGroup : nodeGroups) {
            List<JobPo> deadJobPo = appContext.getExecutableJobQueue().getDeadJob(nodeGroup, SystemClock.now() - MAX_TIME_OUT);
            if (CollectionUtils.isNotEmpty(deadJobPo)) {
                for (JobPo jobPo : deadJobPo) {
                    appContext.getExecutableJobQueue().resume(jobPo);
                    LOGGER.info("Fix executable job : {} ", JSON.toJSONString(jobPo));
                }
            }
        }
    }
Example 8
public boolean add(List<JobFeedbackPo> jobFeedbackPos) {
        if (CollectionUtils.isEmpty(jobFeedbackPos)) {
            return true;
        }
        for (JobFeedbackPo jobFeedbackPo : jobFeedbackPos) {
            String tableName = JobQueueUtils.getFeedbackQueueName(
                    jobFeedbackPo.getJobRunResult().getJobMeta().getJob().getSubmitNodeGroup());
            try {
                template.save(tableName, jobFeedbackPo);
            } catch (DuplicateKeyException e) {
                LOGGER.warn("duplicate key for job feedback po: " + JSON.toJSONString(jobFeedbackPo));
            }
        }
        return true;
    }