本文整理汇总了Java中com.ibm.commons.util.io.json.JsonParser类的典型用法代码示例。如果您正苦于以下问题:Java JsonParser类的具体用法?Java JsonParser怎么用?Java JsonParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonParser类属于com.ibm.commons.util.io.json包,在下文中一共展示了JsonParser类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseConfiguration
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
protected static OneUIApplicationConfiguration parseConfiguration(String path) {
FacesContext ctx = FacesContext.getCurrentInstance();
InputStream is = ctx.getExternalContext().getResourceAsStream(path);
if(is!=null) {
try {
try {
Reader reader = new InputStreamReader(is,"UTF-8"); // $NON-NLS-1$
OneUIJSONFactory factory = new OneUIJSONFactory();
return (OneUIApplicationConfiguration)JsonParser.fromJson(factory, reader);
} finally {
is.close();
}
} catch(Exception ex) {
Platform.getInstance().log(ex);
}
}
return null;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:19,代码来源:OneUIApplicationBean.java
示例2: CouchbaseViewEntry
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
protected CouchbaseViewEntry(final ViewRow row) throws JsonException {
String bbox = null;
String geometry = null;
try {
bbox = row.getBbox();
geometry = row.getGeometry();
} catch (UnsupportedOperationException uoe) {
}
bbox_ = bbox;
geometry_ = geometry;
id_ = row.getId();
key_ = row.getKey();
value_ = row.getValue();
Object docObject = row.getDocument();
if (docObject != null) {
String json = (String) docObject;
JsonJavaObject doc = (JsonJavaObject) JsonParser.fromJson(JsonJavaFactory.instanceEx, json);
data_ = Collections.unmodifiableMap(new HashMap<String, Object>(doc));
} else {
data_ = null;
}
}
开发者ID:jesse-gallagher,项目名称:Couchbase-Data-for-XPages,代码行数:24,代码来源:CouchbaseView.java
示例3: CouchbaseViewEntry
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected CouchbaseViewEntry(final ViewRow row) throws JsonException {
String bbox = null;
String geometry = null;
try {
bbox = row.getBbox();
geometry = row.getGeometry();
} catch (UnsupportedOperationException uoe) {
}
bbox_ = bbox;
geometry_ = geometry;
id_ = row.getId();
key_ = row.getKey();
value_ = row.getValue();
Object docObject = row.getDocument();
if (docObject != null) {
String json = (String) docObject;
JsonJavaObject doc = (JsonJavaObject) JsonParser.fromJson(JsonJavaFactory.instanceEx, json);
data_ = Collections.unmodifiableMap(new HashMap<String, Object>((Map<String, Object>) doc));
} else {
data_ = null;
}
}
开发者ID:jesse-gallagher,项目名称:Couchbase-Data-for-XPages,代码行数:25,代码来源:CouchbaseView.java
示例4: renderService
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
@Override
public void renderService() throws ServiceException {
JsonFactory factory = getJsonFactory();
// Parse the body
try {
InputStream is = getHttpRequest().getInputStream();
Object o = (ObjectObject)JsonParser.fromJson(factory, new InputStreamReader(is,ENCODING_UTF8));
int id = (int)factory.getNumber(factory.getProperty(o, JSON_FACTORY_PROPERTY_ID));
String methodName = factory.getString((factory.getProperty(o, JSON_FACTORY_PROPERTY_METHOD)));
Object params = factory.getProperty(o, JSON_FACTORY_PROPERTY_PARAMS);
Object res = factory.createObject(null, null);
factory.setProperty(res, JSON_FACTORY_PROPERTY_ID, factory.createNumber(id));
RpcMethod method = findMethod(methodName);
if(method!=null) {
Object result = method.invoke(getHttpRequest(), id, params);
factory.setProperty(res, JSON_FACTORY_PROPERTY_RESULT, result);
} else {
factory.setProperty(res, JSON_FACTORY_PROPERTY_ERROR, factory.createString(StringUtil.format("Unknown method {0}", methodName))); // $NLX-RpcServiceEngine.Unknownmethod0-1$
}
getHttpResponse().setContentType(CONTENTTYPE_TEXT_JSON);
getHttpResponse().setCharacterEncoding(ENCODING_UTF8);
OutputStream os = getOutputStream();
Writer w = new OutputStreamWriter(os,ENCODING_UTF8);
JsonGenerator.toJson(factory, w, res, false); // last is "compact"
w.flush();
} catch(Exception ex) {
throw new ServiceException(ex,""); // $NON-NLS-1$
}
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:38,代码来源:RpcServiceEngine.java
示例5: fromJson
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public void fromJson(Document document) throws JsonException {
// SPR #DDEY9L6MX5: Add a Form item
try {
if ( !document.hasItem(FORM_ITEM) ) {
document.replaceItemValue(FORM_ITEM, MEMO_FORM);
}
}
catch (NotesException e) {
// Ignore exception
}
JsonFactory factory = new JsonObjectFactory(document);
JsonParser.fromJson(factory, _reader);
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:16,代码来源:JsonMessageParser.java
示例6: fromJson
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public Delegate fromJson() throws JsonException {
Delegate delegate = null;
JsonFactory factory = new JsonObjectFactory();
JsonParser.fromJson(factory, _reader);
if ( _adapter != null ) {
delegate = _adapter.compose();
}
return delegate;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:13,代码来源:JsonDelegateParser.java
示例7: fromJson
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public MutedThreadUpdate fromJson() throws JsonException, ParseException, ModelException {
final MutedThreadUpdate result = new MutedThreadUpdate();
final JsonJavaObject obj = (JsonJavaObject) JsonParser.fromJson(JsonJavaFactory.instanceEx, _reader);
for (final Entry<String, Object> entry : obj.entrySet()) {
result.setRequestAction(entry.getKey(), validateUNID(entry.getValue()));
}
return result;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:11,代码来源:JsonMutedThreadUpdateParser.java
示例8: parse
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
/**
* Parses a JSON string to an iCal4j Calendar object.
*
* @param jsonInput
* @return
* @throws JsonException
*/
public Calendar parse(Reader jsonInput) throws JsonException {
Calendar calendar = null;
Object object = JsonParser.fromJson(_factory, jsonInput);
if ( object instanceof JsonCalendarAdapter ) {
JsonCalendarAdapter json = (JsonCalendarAdapter)object;
json.composeDeferredProperties();
calendar = json.getCalendar();
}
return calendar;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:21,代码来源:JsonCalendarParser.java
示例9: testParseObjectFromString
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
@Test
public void testParseObjectFromString() throws JsonException {
JsonJavaFactory factory = JsonJavaFactory.instanceEx;
JsonJavaObject json = (JsonJavaObject) JsonParser.fromJson(factory, RESULT);
JsonBinderContainer container = new JsonBinderContainer();
UserMock userMock = new UserMock();
container.processJson2Object(json, userMock);
assertNotNull(userMock);
assertEquals("Marco Müller", userMock.getName());
assertEquals(42, userMock.getAccountNumber());
assertEquals(new Integer(42), userMock.getAccountObject());
assertEquals(3, userMock.getTags().size());
}
开发者ID:OpenNTF,项目名称:XPagesToolkit,代码行数:14,代码来源:Json2ObjectTest.java
示例10: testParseObjectFromStringWithChildren
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
@Test
public void testParseObjectFromStringWithChildren() throws JsonException {
JsonJavaFactory factory = JsonJavaFactory.instanceEx;
JsonJavaObject json = (JsonJavaObject) JsonParser.fromJson(factory, RESULT_CHILDREND);
JsonBinderContainer container = new JsonBinderContainer();
UserMock userMock = new UserMock();
container.processJson2Object(json, userMock);
assertNotNull(userMock);
assertEquals("Marco Müller", userMock.getName());
assertEquals(42, userMock.getAccountNumber());
assertEquals(new Integer(42), userMock.getAccountObject());
assertEquals(3, userMock.getTags().size());
assertEquals(2, userMock.getChildren().size());
assertEquals("René Meier", userMock.getChildren().get(0).getName());
}
开发者ID:OpenNTF,项目名称:XPagesToolkit,代码行数:16,代码来源:Json2ObjectTest.java
示例11: CouchbaseDocument
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public CouchbaseDocument(final String connectionName, final String key) throws IOException, JsonException {
connectionName_ = connectionName;
key_ = key;
CouchbaseClient client = getClient();
// Assume it's always a document
String json = (String) client.get(key_);
data_ = (JsonJavaObject) JsonParser.fromJson(JsonJavaFactory.instanceEx, json);
}
开发者ID:jesse-gallagher,项目名称:Couchbase-Data-for-XPages,代码行数:10,代码来源:CouchbaseDocument.java
示例12: parse
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public Object parse(Reader jsonInput) throws JsonException {
Object result = null;
Object object = JsonParser.fromJson(_factory, jsonInput);
if (object instanceof JsonFrameAdapter) {
JsonFrameAdapter adapter = (JsonFrameAdapter) object;
result = adapter.getFrame();
}
return result;
}
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:12,代码来源:JsonFrameParser.java
示例13: find
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public DumpAccessor find(DumpContext dumpContext, Object o) {
if(o instanceof ComponentParameters) {
ComponentParameters c = (ComponentParameters)o;
// The only access in 852 is through JSON
try {
JsonObject js = (JsonObject)JsonParser.fromJson(JsonJavaFactory.instanceEx,c.getAsJson());
return new JavaScriptDumpFactory.Json(dumpContext,JsonJavaFactory.instanceEx,js);
} catch(Throwable t) {
return new JavaDumpFactory.ExceptionValue(dumpContext,t);
}
}
// Use of JSF registry
if(USE_JSF_REGISTRY) {
if( (o instanceof UIComponent)
|| (o instanceof Converter)
|| (o instanceof Validator)
|| (o instanceof ValueBindingObject)) {
FacesDefinition def = XPagesDumpFactory.findDefinition(dumpContext, o);
if(def!=null) {
return new JSFRegistryValueMap(dumpContext, def, o);
}
}
}
// Regular component as a bean
if(o instanceof UIComponent) {
return JavaDumpFactory.createJavaBean(dumpContext, o, new JavaDumpFactory.JavaBean.IFilter() {
public boolean accept(PropertyDescriptor desc) {
return true;
}
});
}
if(o instanceof HttpServletRequest) {
return new HttpServletRequestMap(dumpContext,(HttpServletRequest)o);
}
if(o instanceof HttpSession) {
return new HttpSessionMap(dumpContext,(HttpSession)o);
}
if(o instanceof Cookie) {
return new CookieMap(dumpContext,(Cookie)o);
}
if(o instanceof SessionData) {
return new SessionDataMap(dumpContext,(SessionData)o);
}
return null;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:46,代码来源:XPagesDumpFactory.java
示例14: fromJson
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public OooStatus fromJson() throws JsonException, ParseException {
Date start = null;
Date end = null;
String subject = null;
String message = null;
boolean sendExternal = true;
boolean appendReturnToSubject = false;
JsonJavaObject obj = (JsonJavaObject)JsonParser.fromJson(JsonJavaFactory.instanceEx, _reader);
boolean enabled = obj.getBoolean(JSON_OOO_ENABLED);
if ( enabled ) {
String value = null;
value = obj.getString(JSON_OOO_START);
if ( value == null ) {
start = new Date();
}
else {
start = ISO8601_UTC.parse(value);
}
value = obj.getString(JSON_OOO_END);
if ( value == null ) {
end = new Date(start.getTime() + ONE_YEAR);
}
else {
end = ISO8601_UTC.parse(value);
}
subject = obj.getString(JSON_OOO_SUBJECT);
message = obj.getString(JSON_OOO_MESSAGE);
Object bool = obj.get(JSON_OOO_SEND_EXTERNAL);
if ( bool instanceof Boolean ) {
sendExternal = (Boolean)bool;
}
bool = obj.get(JSON_OOO_APPEND_RETURN);
if ( bool instanceof Boolean ) {
appendReturnToSubject = (Boolean)bool;
}
}
return new OooStatus(enabled, start, end, subject, message,
sendExternal, appendReturnToSubject);
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:49,代码来源:JsonOooStatusParser.java
示例15: createAction
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
/**
* Creates an Action instance.
*
* @param actionType
* @param contentType
* @param requestEntity
* @return
* @throws JsonException
* @throws ParseException
*/
public static Action createAction(int actionType, String contentType, String requestEntity) throws JsonException, ParseException {
String comments = null;
String delegateTo = null;
Date counterStart = null;
Date counterEnd = null;
Boolean keepInformed = null;
if ( StringUtil.isNotEmpty(requestEntity) ) {
if ( contentType != null && contentType.startsWith(MediaType.APPLICATION_JSON) ) {
Object object = JsonParser.fromJson(JsonJavaFactory.instanceEx, requestEntity);
if ( object instanceof JsonObject ) {
Object property = ((JsonObject)object).getJsonProperty("comments"); // $NON-NLS-1$
if ( property instanceof String ) {
comments = (String)property;
}
property = ((JsonObject)object).getJsonProperty("delegateTo"); // $NON-NLS-1$
if ( property instanceof String ) {
delegateTo = (String)property;
}
property = ((JsonObject)object).getJsonProperty("counterStart"); // $NON-NLS-1$
if ( property instanceof String ) {
counterStart = dateFromString((String)property);
}
property = ((JsonObject)object).getJsonProperty("counterEnd"); // $NON-NLS-1$
if ( property instanceof String ) {
counterEnd = dateFromString((String)property);
}
property = ((JsonObject)object).getJsonProperty("keepInformed"); // $NON-NLS-1$
if ( property instanceof Boolean ) {
keepInformed = (Boolean)property;
}
}
}
else {
throw new WebApplicationException(CalendarService.createErrorResponse("Unsupported media type.", Status.UNSUPPORTED_MEDIA_TYPE)); // $NLX-Utils.Unsupportedmediatype-1$
}
}
Action action = null;
if ( actionType == Action.ACTION_DELEGATE) {
action = new DelegateAction(comments, delegateTo, keepInformed);
}
else if ( actionType == Action.ACTION_DECLINE) {
action = new DeclineAction(comments, keepInformed);
}
else if ( actionType == Action.ACTION_COUNTER ) {
action = new CounterAction(comments, counterStart, counterEnd);
}
else {
action = new Action(actionType, comments);
}
return action;
}
开发者ID:OpenNTF,项目名称:XPagesExtensionLibrary,代码行数:70,代码来源:Utils.java
示例16: checkPassword
import com.ibm.commons.util.io.json.JsonParser; //导入依赖的package包/类
public ExecutionUserProperties checkPassword(String strUser, String strPW, String strURL) {
ExecutionUserProperties eupRC = new ExecutionUserProperties();
eupRC.setLoggedIn(false);
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient = (DefaultHttpClient) ClientSSLResistanceExtender.wrapClient(httpClient);
httpClient.setRedirectStrategy(new DefaultRedirectStrategy());
/*
* String strNSFURL = strURL; String strRedirection = strNSFURL +
* "/xsp/xpage.agent?loginCheck"; java.util.List<NameValuePair>
* formparams = new ArrayList<NameValuePair>(); formparams.add(new
* BasicNameValuePair("username", strUser)); formparams.add(new
* BasicNameValuePair("password", strPW)); formparams.add(new
* BasicNameValuePair("redirectto", strRedirection));
* UrlEncodedFormEntity entity = new
* UrlEncodedFormEntity(formparams, "UTF-8");
*
* HttpPost postRequest = new HttpPost(strNSFURL + "?login");
* postRequest.getParams().setParameter(ClientPNames.COOKIE_POLICY,
* org
* .apache.http.client.params.CookiePolicy.BROWSER_COMPATIBILITY);
*
* postRequest.setHeader("Content-Type",
* "application/x-www-form-urlencoded");
* postRequest.addHeader("accept", "application/json");
* postRequest.setEntity(entity); HttpResponse hsr =
* httpClient.execute(postRequest); for (Cookie ck :
* httpClient.getCookieStore().getCookies()) { if
* ("LtpaToken".equalsIgnoreCase(ck.getName())) { blRC = true; } if
* ("DomAuthSessId".equalsIgnoreCase(ck.getName())) { blRC = true; }
* }
*/
String strNSFURL = strURL;
String strRedirection = strNSFURL + "/xsp/xpage.agent?action=checkLogin";
HttpGet getRequestINIT = new HttpGet(strNSFURL);
HttpGet getRequest = new HttpGet(strRedirection);
getRequest.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials(strUser, strPW), "UTF-8", false));
getRequestINIT.addHeader(BasicScheme.authenticate(new UsernamePasswordCredentials(strUser, strPW), "UTF-8", false));
HttpResponse hsrINTI = httpClient.execute(getRequestINIT);
if (hsrINTI.getStatusLine().getStatusCode() == 200) {
EntityUtils.consume(hsrINTI.getEntity());
HttpResponse hsr = httpClient.execute(getRequest);
JsonJavaObject json = (JsonJavaObject) JsonParser.fromJson(JsonJavaFactory.instanceEx, EntityUtils.toString(hsr.getEntity()));
if (json.getString("status").equalsIgnoreCase("ok")) {
eupRC.setLoggedIn(true);
eupRC.setUserName(json.getString("username"));
eupRC.setAccessLevel(json.getInt("level"));
} else {
eupRC.setLoggedIn(false);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return eupRC;
}
开发者ID:OpenNTF,项目名称:XPagesToolkit,代码行数:60,代码来源:PasswordService.java
注:本文中的com.ibm.commons.util.io.json.JsonParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论