本文整理匯總了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;
}