本文整理汇总了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));
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例7: Extensions
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Extensions(StringOfJSON jsonStr) throws IOException, URISyntaxException {
this(jsonStr.toJSONNode());
}
示例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);
}
示例9: Person
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Person(StringOfJSON jsonStr) throws IOException {
this(jsonStr.toJSONNode());
}
示例10: SubStatement
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public SubStatement (StringOfJSON jsonStr) throws Exception {
super(jsonStr);
}
示例11: StatementBase
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public StatementBase(StringOfJSON jsonStr) throws IOException, URISyntaxException, NoSuchAlgorithmException {
this(jsonStr.toJSONNode());
}
示例12: Activity
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Activity(StringOfJSON jsonStr) throws URISyntaxException, IOException {
this(jsonStr.toJSONNode());
}
示例13: Statement
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public Statement(StringOfJSON jsonStr) throws IOException, URISyntaxException, NoSuchAlgorithmException {
this(jsonStr.toJSONNode());
}
示例14: StatementsResult
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public StatementsResult(StringOfJSON json) throws IOException, URISyntaxException, NoSuchAlgorithmException {
this(json.toJSONNode());
}
示例15: About
import com.rusticisoftware.tincan.json.StringOfJSON; //导入依赖的package包/类
public About(String str) throws IOException, URISyntaxException {
StringOfJSON jsonStr = new StringOfJSON(str);
init(jsonStr.toJSONNode());
}