本文整理汇总了Java中org.json.JSONStringer.key方法的典型用法代码示例。如果您正苦于以下问题:Java JSONStringer.key方法的具体用法?Java JSONStringer.key怎么用?Java JSONStringer.key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.json.JSONStringer
的用法示例。
在下文中一共展示了JSONStringer.key方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJSONString
import org.json.JSONStringer; //导入方法依赖的package包/类
@Override
public void toJSONString(JSONStringer stringer) throws JSONException {
super.toJSONString(stringer);
stringer.key(Members.KEY_ITERATE.name()).value(m_keyIterate);
stringer.key(Members.LOOKUP_TYPE.name()).value(m_lookupType.toString());
stringer.key(Members.SORT_DIRECTION.name()).value(m_sortDirection.toString());
stringer.key(Members.TARGET_INDEX_NAME.name()).value(m_targetIndexName);
stringer.key(Members.END_EXPRESSION.name());
stringer.value(m_endExpression);
stringer.key(Members.SEARCHKEY_EXPRESSIONS.name()).array();
for (AbstractExpression ae : m_searchkeyExpressions) {
assert (ae instanceof JSONString);
stringer.value(ae);
}
stringer.endArray();
}
示例2: toJSONString
import org.json.JSONStringer; //导入方法依赖的package包/类
@Override
public void toJSONString(JSONStringer stringer) throws JSONException {
super.toJSONString(stringer);
stringer.key("AGGREGATE_COLUMNS");
stringer.array();
for (int ii = 0; ii < m_aggregateTypes.size(); ii++) {
stringer.object();
stringer.key(Members.AGGREGATE_TYPE.name()).value(m_aggregateTypes.get(ii).name());
stringer.key(Members.AGGREGATE_NAME.name()).value(m_aggregateColumnNames.get(ii));
stringer.key(Members.AGGREGATE_GUID.name()).value(m_aggregateColumnGuids.get(ii));
stringer.key(Members.AGGREGATE_OUTPUT_COLUMN.name()).value(m_aggregateOutputColumns.get(ii));
stringer.endObject();
}
stringer.endArray();
if (!m_groupByColumnGuids.isEmpty())
{
stringer.key(Members.GROUPBY_COLUMNS.name()).array();
for (int i = 0; i < m_groupByColumnGuids.size(); i++) {
PlanColumn column = m_context.get(m_groupByColumnGuids.get(i));
column.toJSONString(stringer);
}
stringer.endArray();
}
}
示例3: toJsonString
import org.json.JSONStringer; //导入方法依赖的package包/类
public String toJsonString() throws JSONException {
JSONStringer out = new JSONStringer();
out.object();
out.key(JSON_TYPE);
out.value(getTypeName());
if (!TextUtils.isEmpty(mBlockId)) {
out.key(JSON_BLOCK_ID);
out.value(mBlockId);
}
if (!TextUtils.isEmpty(mGroupId)) {
out.key(JSON_GROUP_ID);
out.value(mGroupId);
}
writeJsonAttributes(out);
// Workspace id is not included to reduce size over network.
out.endObject();
return out.toString();
}
示例4: writeJsonAttributes
import org.json.JSONStringer; //导入方法依赖的package包/类
@Override
protected void writeJsonAttributes(JSONStringer out) throws JSONException {
if (mNewParentId != null) {
out.key(JSON_NEW_PARENT_ID);
out.value(mNewParentId);
}
if (mNewInputName != null) {
out.key(JSON_NEW_INPUT_NAME);
out.value(mNewInputName);
}
if (mHasNewPosition) {
out.key(JSON_NEW_COORDINATE);
StringBuilder sb = new StringBuilder();
sb.append(mNewPositionX).append(',').append(mNewPositionY);
out.value(sb.toString());
}
}
示例5: toBundle
import org.json.JSONStringer; //导入方法依赖的package包/类
public void toBundle(Bundle bundle) {
super.toBundle(bundle);
JSONStringer jSONStringer = new JSONStringer();
try {
jSONStringer.object();
jSONStringer.key("card_list");
jSONStringer.array();
for (WXCardItem wXCardItem : this.cardArrary) {
jSONStringer.object();
jSONStringer.key("card_id");
jSONStringer.value(wXCardItem.cardId);
jSONStringer.key("card_ext");
jSONStringer.value(wXCardItem.cardExtMsg == null ? "" : wXCardItem.cardExtMsg);
jSONStringer.endObject();
}
jSONStringer.endArray();
jSONStringer.endObject();
} catch (Exception e) {
e.printStackTrace();
}
bundle.putString("_wxapi_add_card_to_wx_card_list", jSONStringer.toString());
}
示例6: fieldsToJSON
import org.json.JSONStringer; //导入方法依赖的package包/类
/**
* For a given list of Fields, write out the contents of the corresponding
* field to the JSONObject The each of the JSONObject's elements will be the
* upper case version of the Field's name
*
* @param <T>
* @param stringer
* @param object
* @param base_class
* @param fields
* @throws JSONException
*/
public static <T> void fieldsToJSON(JSONStringer stringer, T object, Class<? extends T> base_class, Field fields[]) throws JSONException {
if (debug.val)
LOG.debug("Serializing out " + fields.length + " elements for " + base_class.getSimpleName());
for (Field f : fields) {
String json_key = f.getName().toUpperCase();
stringer.key(json_key);
try {
Class<?> f_class = f.getType();
Object f_value = f.get(object);
// Null
if (f_value == null) {
writeFieldValue(stringer, f_class, f_value);
// Maps
} else if (f_value instanceof Map) {
writeFieldValue(stringer, f_class, f_value);
// Everything else
} else {
writeFieldValue(stringer, f_class, f_value);
addClassForField(stringer, json_key, f_class, f_value);
}
} catch (Exception ex) {
throw new JSONException(ex);
}
} // FOR
}
示例7: toJSONString
import org.json.JSONStringer; //导入方法依赖的package包/类
public void toJSONString(JSONStringer stringer) throws JSONException
{
stringer.object();
stringer.key(Members.GUID.name()).value(guid());
stringer.key(Members.NAME.name()).value(getDisplayName());
stringer.key(Members.TYPE.name()).value(type().name());
stringer.key(Members.SIZE.name()).value(width());
stringer.key(Members.SORT_ORDER.name()).value(m_sortOrder.name());
stringer.key(Members.STORAGE.name()).value(m_storage.name());
if (originTableName() != null) {
stringer.key(Members.INPUT_TABLE_NAME.name()).value(originTableName());
}
else
{
stringer.key(Members.INPUT_TABLE_NAME.name()).value("");
}
if (originColumnName() != null) {
stringer.key(Members.INPUT_COLUMN_NAME.name()).value(originColumnName());
}
else
{
stringer.key(Members.INPUT_COLUMN_NAME.name()).value("");
}
if (m_expression != null) {
stringer.key(Members.EXPRESSION.name());
stringer.object();
m_expression.toJSONString(stringer);
stringer.endObject();
}
else
{
stringer.key(Members.EXPRESSION.name()).value("");
}
stringer.endObject();
}
示例8: toJSONString
import org.json.JSONStringer; //导入方法依赖的package包/类
@Override
public void toJSONString(JSONStringer stringer) throws JSONException {
super.toJSONString(stringer);
stringer.key(Members.VALUE.name());
if (m_isNull)
{
stringer.value("NULL");
}
else
{
switch (m_valueType)
{
case INVALID:
throw new JSONException("ConstantValueExpression.toJSONString(): value_type should never be VoltType.INVALID");
case NULL:
throw new JSONException("ConstantValueExpression.toJSONString(): And they should be never be this either! VoltType.NULL");
case TINYINT:
stringer.value(Long.valueOf(m_value));
break;
case SMALLINT:
stringer.value(Long.valueOf(m_value));
break;
case INTEGER:
stringer.value(Long.valueOf(m_value));
break;
case BIGINT:
stringer.value(Long.valueOf(m_value));
break;
case FLOAT:
stringer.value(Double.valueOf(m_value));
break;
case STRING:
stringer.value(m_value);
break;
case TIMESTAMP:
stringer.value(Long.valueOf(m_value));
break;
case DECIMAL:
stringer.value(m_value);
break;
default:
throw new JSONException("ConstantValueExpression.toJSONString(): Unrecognized value_type " + m_valueType);
}
}
}
示例9: toJson
import org.json.JSONStringer; //导入方法依赖的package包/类
public CharSequence toJson() {
try {
JSONStringer writer = new JSONStringer();
writer.object();
Json.writeObject(writer, "minimumInputLength", minimumInputLength);
Json.writeObject(writer, "minimumResultsForSearch", minimumResultsForSearch);
Json.writeObject(writer, "maximumSelectionSize", maximumSelectionSize);
Json.writeObject(writer, "placeholder", placeholder);
Json.writeObject(writer, "allowClear", allowClear);
Json.writeObject(writer, "multiple", multiple);
Json.writeObject(writer, "closeOnSelect", closeOnSelect);
Json.writeFunction(writer, "id", id);
Json.writeFunction(writer, "matcher", matcher);
Json.writeFunction(writer, "tokenizer", tokenizer);
Json.writeFunction(writer, "sortResults", sortResults);
Json.writeFunction(writer, "formatSelection", formatSelection);
Json.writeFunction(writer, "formatResult", formatResult);
Json.writeFunction(writer, "formatNoMatches", formatNoMatches);
Json.writeFunction(writer, "formatInputTooShort", formatInputTooShort);
Json.writeFunction(writer, "formatResultCssClass", formatResultCssClass);
Json.writeFunction(writer, "formatSelectionTooBig", formatSelectionTooBig);
Json.writeFunction(writer, "formatLoadMore", formatLoadMore);
Json.writeFunction(writer, "formatSearching", formatSearching);
Json.writeFunction(writer, "escapeMarkup", escapeMarkup);
Json.writeFunction(writer, "createSearchChoice", createSearchChoice);
Json.writeFunction(writer, "initSelection", initSelection);
Json.writeFunction(writer, "query", query);
Json.writeObject(writer, "width", width);
Json.writeObject(writer, "openOnEnter", openOnEnter);
Json.writeFunction(writer, "containerCss", containerCss);
Json.writeObject(writer, "containerCssClass", containerCssClass);
Json.writeFunction(writer, "dropdownCss", dropdownCss);
Json.writeObject(writer, "dropdownCssClass", dropdownCssClass);
Json.writeObject(writer, "separator", separator);
Json.writeObject(writer, "tokenSeparators", tokenSeparators);
Json.writeObject(writer, "dropdownAutoWidth", dropdownAutoWidth);
if (ajax != null) {
writer.key("ajax");
ajax.toJson(writer);
}
Json.writeFunction(writer, "data", data);
Json.writeFunction(writer, "tags", tags);
writer.endObject();
return writer.toString();
} catch (JSONException e) {
throw new RuntimeException("Could not convert Select2 settings object to Json", e);
}
}