本文整理汇总了Java中com.alibaba.fastjson.JSONObject.size方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.size方法的具体用法?Java JSONObject.size怎么用?Java JSONObject.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.JSONObject
的用法示例。
在下文中一共展示了JSONObject.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromJSON
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* 提取键值对。
*
* @param jsonObject 要提取的json对象
* @return 提取结果
*/
public static SimpleAppValues fromJSON(JSONObject jsonObject)
{
SimpleAppValues simpleAppValues = new SimpleAppValues();
String[] names = new String[jsonObject.size()];
Object[] values = new Object[jsonObject.size()];
simpleAppValues.names = names;
simpleAppValues.values = values;
Iterator<Map.Entry<String, Object>> iterator = jsonObject.entrySet().iterator();
int i = 0;
while (iterator.hasNext())
{
Map.Entry<String, Object> entry = iterator.next();
names[i] = entry.getKey();
values[i++] = entry.getValue();
}
return simpleAppValues;
}
示例2: parseInner
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* Parse the jsonObject to {@link WXDomObject} recursively
* @param map the original JSONObject
* @return Dom Object corresponding to the JSONObject.
*/
private @Nullable WXDomObject parseInner(JSONObject map) {
if (map == null || map.size() <= 0) {
return null;
}
String type = (String) map.get(TYPE);
WXDomObject domObject = WXDomObjectFactory.newInstance(type);
if(domObject == null){
return null;
}
domObject.parseFromJson(map);
Object children = map.get(CHILDREN);
if (children != null && children instanceof JSONArray) {
JSONArray childrenArray = (JSONArray) children;
int count = childrenArray.size();
for (int i = 0; i < count; ++i) {
domObject.add(parseInner(childrenArray.getJSONObject(i)),-1);
}
}
return domObject;
}
示例3: DefaultLogFilterAndRule
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* 构造默认的日志规则
*
* @param filterregex
* 日志过滤规则的正则表达式
* @param separator
* 日志字段分隔符
* @param fields
* 日志字段名以及对应在的列号
* @param fieldNumber
* 指定对应的列号值为时间戳
* @param version
* 规则当前的版本
*/
public DefaultLogFilterAndRule(String filterregex, String separator, JSONObject fields, int fieldNumber,
int version) {
this.filterPattern = Pattern.compile(filterregex);
this.separator = Splitter.on(separator).trimResults();
this.SpecifiedFields = new Integer[fields.size()];
this.fieldsName = new String[fields.size()];
int i = 0;
for (Entry<String, Object> entry : fields.entrySet()) {
fieldsName[i] = entry.getKey();
SpecifiedFields[i++] = (Integer) entry.getValue();
}
this.timeStampField = fieldNumber;
this.version = version;
@SuppressWarnings("rawtypes")
List<Map> mainlogs = Lists.newLinkedList();
setMainlogs(mainlogs);
}
示例4: toNameValues
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
public static NameValues toNameValues(JSONObject jsonObject)
{
NameValues nameValues = new NameValues(jsonObject.size());
for (Map.Entry<String, Object> entry : jsonObject.entrySet())
{
nameValues.append(entry.getKey(), entry.getValue());
}
return nameValues;
}
示例5: parseFromJson
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* Parse the jsonObject to {@link WXDomObject} recursively
* @param map the original JSONObject
*/
public void parseFromJson(JSONObject map){
if (map == null || map.size() <= 0) {
return;
}
String type = (String) map.get("type");
this.type = type;
this.ref = (String) map.get("ref");
Object style = map.get("style");
if (style != null && style instanceof JSONObject) {
WXStyle styles = new WXStyle();
WXJsonUtils.putAll(styles, (JSONObject) style);
this.style = styles;
}
Object attr = map.get("attr");
if (attr != null && attr instanceof JSONObject) {
WXAttr attrs = new WXAttr();
WXJsonUtils.putAll(attrs, (JSONObject) attr);
this.attr = attrs;
}
Object event = map.get("event");
if (event != null && event instanceof JSONArray) {
WXEvent events = new WXEvent();
JSONArray eventArray = (JSONArray) event;
int count = eventArray.size();
for (int i = 0; i < count; ++i) {
events.add(eventArray.getString(i));
}
this.event = events;
}
}
示例6: updateAttrs
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* Update attributes
* @param ref
* @param attr the expected attr
*/
public void updateAttrs(String ref, JSONObject attr) {
if (TextUtils.isEmpty(ref) || attr == null || attr.size() < 1) {
return;
}
Message msg = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = mWXSDKInstance.getInstanceId();
task.args = new ArrayList<>();
task.args.add(ref);
task.args.add(attr);
msg.what = WXDomHandler.MsgType.WX_DOM_UPDATE_ATTRS;
msg.obj = task;
WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
}
示例7: updateStyle
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* Update DOM style.
* @param ref DOM reference
* @param style the expected style
*/
public void updateStyle(String ref, JSONObject style) {
if (TextUtils.isEmpty(ref) || style == null || style.size() < 1) {
return;
}
Message msg = Message.obtain();
WXDomTask task = new WXDomTask();
task.instanceId = mWXSDKInstance.getInstanceId();
task.args = new ArrayList<>();
task.args.add(ref);
task.args.add(style);
msg.what = WXDomHandler.MsgType.WX_DOM_UPDATE_STYLE;
msg.obj = task;
WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
}
示例8: parseFromJson
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* Parse the jsonObject to {@link WXDomObject} recursively
* @param map the original JSONObject
*/
public void parseFromJson(JSONObject map){
if (map == null || map.size() <= 0) {
return;
}
String type = (String) map.get("type");
this.mType = type;
this.mRef = (String) map.get("ref");
Object style = map.get("style");
if (style != null && style instanceof JSONObject) {
WXStyle styles = new WXStyle();
styles.putAll((JSONObject) style,false);
this.mStyles = styles;
}
Object attr = map.get("attr");
if (attr != null && attr instanceof JSONObject) {
WXAttr attrs = new WXAttr((JSONObject) attr);
//WXJsonUtils.putAll(attrs, (JSONObject) attr);
this.mAttributes = attrs;
}
Object event = map.get("event");
if (event != null && event instanceof JSONArray) {
WXEvent events = new WXEvent();
JSONArray eventArray = (JSONArray) event;
int count = eventArray.size();
for (int i = 0; i < count; ++i) {
events.add(eventArray.getString(i));
}
this.mEvents = events;
}
}
示例9: hasSameColumns
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private boolean hasSameColumns(JSONArray header, JSONObject objItem) {
if (objItem.size() != header.size()) return false;
for (String obj : objItem.keySet())
if (!header.contains(obj)) return false;
return true;
}
示例10: insert
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* <B>方法名称:</B>单表INSERT方法<BR>
* <B>概要说明:</B>单表INSERT方法<BR>
* @param tableName 表名
* @param data JSONObject对象
*/
protected int insert(String tableName, JSONObject data) {
if (data.size() <= 0) {
return 0;
}
StringBuffer sql = new StringBuffer();
sql.append(" INSERT INTO ");
sql.append(tableName + " ( ");
Set<Entry<String, Object>> set = data.entrySet();
List<Object> sqlArgs = new ArrayList<Object>();
for (Iterator<Entry<String, Object>> iterator = set.iterator(); iterator.hasNext();) {
Entry<String, Object> entry = (Entry<String, Object>) iterator.next();
sql.append(entry.getKey() + ",");
sqlArgs.add(entry.getValue());
}
sql.delete(sql.length() - 1, sql.length());
sql.append(" ) VALUES ( ");
for (int i = 0; i < set.size(); i++) {
sql.append("?,");
}
sql.delete(sql.length() - 1, sql.length());
sql.append(" ) ");
return this.getJdbcTemplate().update(sql.toString(), sqlArgs.toArray());
}
示例11: selectByPrimaryKey
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@RequestMapping(value = "/{id}/{table}/{primaryKey}", method = RequestMethod.GET)
@ResponseBody
public Object selectByPrimaryKey(@PathVariable(value = "id") Integer id,
@PathVariable(value = "table") String table,
@PathVariable(value = "primaryKey") String primaryKey) throws Exception {
Datasource one = datasourceService.findOne(id);
Connection connection = DriverManager.getConnection(one.getJdbcUrl(), one.getUsername(), one.getPassword());
String column = TblUtil.getPrimaryKey(connection, table);
String sql = "select * from `" + table + "` where `" + column + "`= '" + primaryKey + "'";
if (TblUtil.isNumber(TblUtil.getColunmType(connection, table, column))) {
sql = "select * from `" + table + "` where `" + column + "`= " + primaryKey;
}
logger.info(sql);
PreparedStatement statement = connection.prepareStatement(sql);
statement.execute();
ResultSetMetaData metaData = statement.getMetaData();
ResultSet statementResultSet = statement.getResultSet();
JSONObject row = new JSONObject();
while (statementResultSet.next()) {
for (int i = 1; i < metaData.getColumnCount() + 1; i++) {
String columnName = metaData.getColumnName(i);
String fieldName = VelocityUtil.toHump(columnName);
Object object = statementResultSet.getObject(columnName);
row.put(fieldName, object);
}
}
statementResultSet.close();
statement.close();
connection.close();
return row.size() > 0 ? row : null;
}
示例12: parse
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* Parse the jsonObject to {@link WXDomObject} recursively
* @param json the original JSONObject
* @return Dom Object corresponding to the JSONObject.
*/
public static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance){
if (json == null || json.size() <= 0) {
return null;
}
String type = (String) json.get(TYPE);
WXDomObject domObject = WXDomObjectFactory.newInstance(type);
domObject.setViewPortWidth(wxsdkInstance.getViewPortWidth());
if(domObject == null){
return null;
}
domObject.parseFromJson(json);
domObject.mDomContext = wxsdkInstance;
Object children = json.get(CHILDREN);
if (children != null && children instanceof JSONArray) {
JSONArray childrenArray = (JSONArray) children;
int count = childrenArray.size();
for (int i = 0; i < count; ++i) {
domObject.add(parse(childrenArray.getJSONObject(i),wxsdkInstance),-1);
}
}
return domObject;
}
示例13: parse
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
/**
* Parse the jsonObject to {@link WXDomObject} recursively
* @param json the original JSONObject
* @return Dom Object corresponding to the JSONObject.
*/
public static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance){
if (json == null || json.size() <= 0) {
return null;
}
String type = (String) json.get(TYPE);
if (wxsdkInstance.isNeedValidate()) {
WXValidateProcessor processor = WXSDKManager.getInstance()
.getValidateProcessor();
if (processor != null) {
WXValidateProcessor.WXComponentValidateResult result = processor
.onComponentValidate(wxsdkInstance, type);
if (result != null && !result.isSuccess) {
type = TextUtils.isEmpty(result.replacedComponent) ? WXBasicComponentType.DIV
: result.replacedComponent;
json.put(TYPE, type);
if(WXEnvironment.isApkDebugable()&&result.validateInfo!=null){
String tag = "[WXDomObject]onComponentValidate failure. >>> "+result.validateInfo.toJSONString();
WXLogUtils.e(tag);
}
}
}
}
WXDomObject domObject = WXDomObjectFactory.newInstance(type);
domObject.setViewPortWidth(wxsdkInstance.getInstanceViewPortWidth());
if(domObject == null){
return null;
}
domObject.parseFromJson(json);
domObject.mDomContext = wxsdkInstance;
Object children = json.get(CHILDREN);
if (children != null && children instanceof JSONArray) {
JSONArray childrenArray = (JSONArray) children;
int count = childrenArray.size();
for (int i = 0; i < count; ++i) {
domObject.add(parse(childrenArray.getJSONObject(i),wxsdkInstance),-1);
}
}
return domObject;
}
示例14: HttpGetFilterTest
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
@Test
public void HttpGetFilterTest() {
SqlParser parser = new SqlParser();
Query q = null;
Object o = new Object();
JSONArray jsonArray = null;
int num = 0, cou = 0;
while (true) {
o = HttpUtil.HttpGet(Settings.PRESTO_QUERY);
jsonArray = JSON.parseArray(o.toString());
String queryId = null;
String query = null;
for (int i = count; i < jsonArray.size(); i++) {
System.out.println("Loop Times: " + num);
JSONObject jsonObject = (JSONObject) jsonArray.get(i);
if (jsonObject.size() == 8) {
queryId = jsonObject.get("queryId").toString();
query = jsonObject.get("query").toString();
// System.out.println(queryId + "\t" + i + "\t" + query);
// Parser
try {
q = (Query) parser.createStatement(query);
} catch (Exception e) {
ExceptionHandler.Instance().log(ExceptionType.ERROR, "query error", e);
}
// System.out.println(q.toString());
QuerySpecification queryBody = (QuerySpecification) q.getQueryBody();
// get columns
List<SelectItem> selectItemList = queryBody.getSelect().getSelectItems();
for (SelectItem column : selectItemList) {
System.out.println(column.toString());
}
// tableName
Table t = (Table) queryBody.getFrom().get();
System.out.println(t.getName());
if (t.getName().equals("text")) {
System.out.println("Text visit: " + cou++);
}
}
}
// update count
count = jsonArray.size();
num++;
o = new Object();
}
}
示例15: isCompactedArrayFormat
import com.alibaba.fastjson.JSONObject; //导入方法依赖的package包/类
private boolean isCompactedArrayFormat(JSONObject object) {
return object.size() == 2
&& object.containsKey("_h")
&& object.containsKey("_d");
}