当前位置: 首页>>代码示例>>Java>>正文


Java StringOfJSON类代码示例

本文整理汇总了Java中com.rusticisoftware.tincan.json.StringOfJSON的典型用法代码示例。如果您正苦于以下问题:Java StringOfJSON类的具体用法?Java StringOfJSON怎么用?Java StringOfJSON使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringOfJSON类属于com.rusticisoftware.tincan.json包,在下文中一共展示了StringOfJSON类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serializeDeserialize

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
@Test
public void serializeDeserialize() throws Exception {
    Map<String, String> ids = new LinkedHashMap<String, String>();
    ids.put("mbox", "mailto:[email protected]");
    ids.put("openid", "http://openid.org/joeuser");
    ids.put("mbox_sha1sum", "b623062e19c5608ab0e1342e5011d48292ce00e3");
    ids.put("account", "http://example.com|joeuser");
    
    String name = "Joe User";
    for (String idType : ids.keySet()) {
        for (TCAPIVersion version : TCAPIVersion.values()) {
            Agent agent = getAgent(name, idType, ids.get(idType));
            String agentJson = agent.toJSON(version);
            Agent clone = Agent.fromJson(new StringOfJSON(agentJson).toJSONNode());
            assertEquals(agentJson, clone.toJSON(version));
        }
    }
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:19,代码来源:AgentTest.java

示例2: getStatement

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
private StatementLRSResponse getStatement(HashMap<String, String> params) {
    HTTPRequest request = new HTTPRequest();
    request.setMethod(HttpMethod.GET.asString());
    request.setResource("statements");
    request.setQueryParams(params);

    HTTPResponse response = makeSyncRequest(request);
    int status = response.getStatus();

    StatementLRSResponse lrsResponse = new StatementLRSResponse(request, response);

    if (status == 200) {
        lrsResponse.setSuccess(true);
        try {
            JsonNode contentNode = (new StringOfJSON(response.getContent())).toJSONNode();
            if (! (contentNode.findPath("statements").isMissingNode())) {
                contentNode = contentNode.findPath("statements").get(0);
            }

            Statement stmt = new Statement (contentNode);
            for (Map.Entry<String, byte[]> entry : response.getAttachments().entrySet()) {
                for (Attachment a : stmt.getAttachments()) {
                    if (entry.getKey().equals(a.getSha2())) {
                        a.setContent(entry.getValue());
                    }
                }
            }

            lrsResponse.setContent(stmt);
        } catch (Exception ex) {
            lrsResponse.setErrMsg("Exception: " + ex.toString());
            lrsResponse.setSuccess(false);
        }
    }
    else {
        lrsResponse.setSuccess(false);
    }

    return lrsResponse;
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:41,代码来源:RemoteLRS.java

示例3: moreStatements

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
@Override
public StatementsResultLRSResponse moreStatements(String moreURL) {
    if (moreURL == null) {
        return null;
    }

    // moreURL is relative to the endpoint's server root
    URL endpoint = this.getEndpoint();
    String url = endpoint.getProtocol() + "://" + endpoint.getHost() + (endpoint.getPort() == -1 ? "" : ":" + endpoint.getPort()) + moreURL;

    HTTPRequest request = new HTTPRequest();
    request.setResource(url);
    request.setMethod(HttpMethod.GET.asString());
    HTTPResponse response = makeSyncRequest(request);

    StatementsResultLRSResponse lrsResponse = new StatementsResultLRSResponse(request, response);

    if (response.getStatus() == 200) {
        lrsResponse.setSuccess(true);
        try {
            lrsResponse.setContent(new StatementsResult(new StringOfJSON(response.getContent())));
        } catch (Exception ex) {
            lrsResponse.setErrMsg("Exception: " + ex.toString());
            lrsResponse.setSuccess(false);
        }
    }
    else {
        lrsResponse.setSuccess(false);
    }

    return lrsResponse;
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:33,代码来源:RemoteLRS.java

示例4: retrieveActivity

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
@Override
public ActivityLRSResponse retrieveActivity(Activity activity) {
    HTTPRequest request = new HTTPRequest();
    request.setMethod(HttpMethod.GET.asString());
    request.setResource("activities");
    request.setQueryParams(new HashMap<String, String>());
    request.getQueryParams().put("activityId", activity.getId().toString());

    HTTPResponse response = makeSyncRequest(request);
    int status = response.getStatus();

    ActivityLRSResponse lrsResponse = new ActivityLRSResponse(request, response);

    if (status == 200) {
        lrsResponse.setSuccess(true);
        try {
            lrsResponse.setContent(new Activity(new StringOfJSON(response.getContent())));
        } catch (Exception ex) {
            lrsResponse.setErrMsg("Exception: " + ex.toString());
            lrsResponse.setSuccess(false);
        }
    }
    else {
        lrsResponse.setSuccess(false);
    }

    return lrsResponse;
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:29,代码来源:RemoteLRS.java

示例5: retrievePerson

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
@Override
public PersonLRSResponse retrievePerson(Agent agent) {
    HTTPRequest request = new HTTPRequest();
    request.setMethod(HttpMethod.GET.asString());
    request.setResource("agents");
    request.setQueryParams(new HashMap<String, String>());
    request.getQueryParams().put("agent", agent.toJSON(this.getVersion(), this.usePrettyJSON()));

    HTTPResponse response = makeSyncRequest(request);
    int status = response.getStatus();

    PersonLRSResponse lrsResponse = new PersonLRSResponse(request, response);

    if (status == 200) {
        lrsResponse.setSuccess(true);
        try {
            lrsResponse.setContent(new Person(new StringOfJSON(response.getContent())));
        } catch (Exception ex) {
            lrsResponse.setErrMsg("Exception: " + ex.toString());
            lrsResponse.setSuccess(false);
        }
    }
    else {
        lrsResponse.setSuccess(false);
    }

    return lrsResponse;
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:29,代码来源:RemoteLRS.java

示例6: JSONString

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
String JSONString(State state)
{
    StringOfJSON json = new StringOfJSON(state.getContents().toString());
    String returnString = json.toString();
    returnString = returnString.replace("\\", "");
    return returnString;
}
 
开发者ID:RusticiSoftware,项目名称:TinCanAndroid-Offline,代码行数:8,代码来源:RSTinCanOfflineConnector.java

示例7: Extensions

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Extensions(StringOfJSON jsonStr) throws IOException, URISyntaxException {
    this(jsonStr.toJSONNode());
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:4,代码来源:Extensions.java

示例8: put

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Object put(URI key, StringOfJSON val) {
    JsonNode storeVal = Mapper.getInstance().valueToTree(val);
    return this.put(key, storeVal);
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:5,代码来源:Extensions.java

示例9: Person

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Person(StringOfJSON jsonStr) throws IOException {
    this(jsonStr.toJSONNode());
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:4,代码来源:Person.java

示例10: SubStatement

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public SubStatement (StringOfJSON jsonStr) throws Exception {
    super(jsonStr);
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:4,代码来源:SubStatement.java

示例11: StatementBase

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public StatementBase(StringOfJSON jsonStr) throws IOException, URISyntaxException, NoSuchAlgorithmException {
    this(jsonStr.toJSONNode());
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:4,代码来源:StatementBase.java

示例12: Activity

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Activity(StringOfJSON jsonStr) throws URISyntaxException, IOException {
    this(jsonStr.toJSONNode());
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:4,代码来源:Activity.java

示例13: Statement

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Statement(StringOfJSON jsonStr) throws IOException, URISyntaxException, NoSuchAlgorithmException {
    this(jsonStr.toJSONNode());
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:4,代码来源:Statement.java

示例14: StatementsResult

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public StatementsResult(StringOfJSON json) throws IOException, URISyntaxException, NoSuchAlgorithmException {
    this(json.toJSONNode());
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:4,代码来源:StatementsResult.java

示例15: About

import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public About(String str) throws IOException, URISyntaxException {
    StringOfJSON jsonStr = new StringOfJSON(str);
    init(jsonStr.toJSONNode());
}
 
开发者ID:RusticiSoftware,项目名称:TinCanJava,代码行数:5,代码来源:About.java


注:本文中的com.rusticisoftware.tincan.json.StringOfJSON类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。