// Path: src/main/java/com/github/quartzweb/utils/json/JSONUtils.java
// public class JSONUtils {
// 
//     public static String toJSONString(Object o) {
//         JSONWriter writer = new JSONWriter();
//         writer.writeObject(o);
//         return writer.toString();
//     }
//     
//     public static Object parse(String text) {
//         JSONParser parser = new JSONParser(text);
//         return parser.parse();
//     }
// }


import java.util.Map;
import com.github.quartzweb.utils.json.JSONUtils;
import java.util.LinkedHashMap;
/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.github.quartzweb.service;



/**
 * @author quxiucheng [quxiuchengdev@gmail.com]
 */
public class JSONResult {

    /**
     * 返回结果code
     */
    private int resultCode;

    /**
     * 返回结果
     */
    private Object content;

    /**
     * 返回json结果-成功(1)
     */
    public static final int RESULT_CODE_SUCCESS = 1;

    /**
     * 返回json结果-失败(-1)
     */
    public static final int RESULT_CODE_ERROR = -1;

    public JSONResult(int resultCode, Object content) {
        this.resultCode = resultCode;
        this.content = content;
    }

    /**
     * 创建一个json结果
     * @param resultCode
     * @param content
     * @return
     */
    public static JSONResult build(int resultCode, Object content){
        return new JSONResult(resultCode, content);
    }

    public String json() {
        Map<String, Object> dataMap = new LinkedHashMap<String, Object>();
        dataMap.put("resultCode", this.resultCode);
        dataMap.put("content", this.content);
// Path: src/main/java/com/github/quartzweb/utils/json/JSONUtils.java
// public class JSONUtils {
// 
//     public static String toJSONString(Object o) {
//         JSONWriter writer = new JSONWriter();
//         writer.writeObject(o);
//         return writer.toString();
//     }
//     
//     public static Object parse(String text) {
//         JSONParser parser = new JSONParser(text);
//         return parser.parse();
//     }
// }


// Path: src/main/java/com/github/quartzweb/service/JSONResult.java
import java.util.Map;
import com.github.quartzweb.utils.json.JSONUtils;
import java.util.LinkedHashMap;

/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.github.quartzweb.service;



/**
 * @author quxiucheng [quxiuchengdev@gmail.com]
 */
public class JSONResult {

    /**
     * 返回结果code
     */
    private int resultCode;

    /**
     * 返回结果
     */
    private Object content;

    /**
     * 返回json结果-成功(1)
     */
    public static final int RESULT_CODE_SUCCESS = 1;

    /**
     * 返回json结果-失败(-1)
     */
    public static final int RESULT_CODE_ERROR = -1;

    public JSONResult(int resultCode, Object content) {
        this.resultCode = resultCode;
        this.content = content;
    }

    /**
     * 创建一个json结果
     * @param resultCode
     * @param content
     * @return
     */
    public static JSONResult build(int resultCode, Object content){
        return new JSONResult(resultCode, content);
    }

    public String json() {
        Map<String, Object> dataMap = new LinkedHashMap<String, Object>();
        dataMap.put("resultCode", this.resultCode);
        dataMap.put("content", this.content);
        return JSONUtils.toJSONString(dataMap);