本文整理汇总了Java中org.codehaus.jettison.json.JSONObject.keys方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.keys方法的具体用法?Java JSONObject.keys怎么用?Java JSONObject.keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jettison.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.keys方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValues
import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private void getValues(final JSONObject object, String type) throws JSONException {
if (type == null) {
type = object.getString(typeKey);
transferId = object.getString(transferIdKey);
}
final Iterator<String> keys = object.keys();
while (keys.hasNext()) {
final String key = keys.next();
try {
final JSONObject child = object.getJSONObject(key);
getValues(child, key);
} catch (final JSONException e) {
if (!key.equals(typeKey) && !key.equals(transferIdKey)) {
final String value = object.getString(key);
cache.put(type, key, value);
}
}
}
}
示例2: readPropertyModels
import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private void readPropertyModels(JSONObject root) {
try {
JSONObject props = root.getJSONObject("Props");
@SuppressWarnings("unchecked")
Iterator<String> it = props.keys();
while (it.hasNext()) {
String key = it.next();
if (!key.isEmpty()) {
IonProperty property = new IonProperty(props.getJSONObject(key));
property.setName(key);
pCache.put(key, property);
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: getProperties
import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public Map<String, IonProperty> getProperties() {
Map<String, IonProperty> properties = new HashMap<String, IonProperty>();
try {
JSONObject jsonProperties = jsonBean.getJSONObject(Key.properties.name());
@SuppressWarnings("unchecked")
Iterator<String> it = jsonProperties.keys();
while (it.hasNext()) {
String pkey = it.next();
if (!pkey.isEmpty()) {
Object ob = jsonProperties.get(pkey);
if (ob instanceof JSONObject) {
IonProperty property = new IonProperty((JSONObject)ob);
property.setName(pkey);
properties.put(property.getName(), property);
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return properties;
}
示例4: getEvents
import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public Map<String, IonEvent> getEvents() {
Map<String, IonEvent> events = new HashMap<String, IonEvent>();
try {
JSONObject jsonEvents = jsonBean.getJSONObject(Key.events.name());
@SuppressWarnings("unchecked")
Iterator<String> it = jsonEvents.keys();
while (it.hasNext()) {
String pkey = it.next();
if (!pkey.isEmpty()) {
Object ob = jsonEvents.get(pkey);
if (ob instanceof JSONObject) {
IonEvent event = new IonEvent((JSONObject)ob);
event.setName(pkey);
events.put(event.getName(), event);
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
return events;
}
示例5: toBeanData
import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public String toBeanData() {
String s = jsonBean.toString();
try {
JSONObject jsonOb = new JSONObject(toString());
for (Key k: Key.values()) {
if (k.equals(Key.name))
continue;
if (k.equals(Key.properties)) {
JSONObject jsonProperties = jsonOb.getJSONObject(Key.properties.name());
if (jsonProperties != null) {
@SuppressWarnings("unchecked")
Iterator<String> it = jsonProperties.keys();
while (it.hasNext()) {
String pkey = it.next();
if (!pkey.isEmpty()) {
Object ob = jsonProperties.get(pkey);
if (ob instanceof JSONObject) {
JSONObject jsonProperty = (JSONObject)ob;
for (IonProperty.Key kp: IonProperty.Key.values()) {
if (kp.equals(IonProperty.Key.name)) continue;
if (kp.equals(IonProperty.Key.mode)) continue;
if (kp.equals(IonProperty.Key.value)) continue;
jsonProperty.remove(kp.name());
}
jsonProperties.put(pkey, jsonProperty);
}
}
}
jsonOb.put(Key.properties.name(), jsonProperties);
continue;
}
}
jsonOb.remove(k.name());
}
s = jsonOb.toString();
} catch (JSONException e) {
e.printStackTrace();
}
//System.out.println(s);
return s;
}