本文整理了Java中org.codehaus.jettison.json.JSONObject.keys()
方法的一些代码示例,展示了JSONObject.keys()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.keys()
方法的具体详情如下:
包路径:org.codehaus.jettison.json.JSONObject
类名称:JSONObject
方法名:keys
[英]Get an enumeration of the keys of the JSONObject.
[中]获取JSONObject键的枚举。
代码示例来源:origin: json-path/JsonPath
private JettisonObjectIterator(org.codehaus.jettison.json.JSONObject jsonObject)
{
this.jsonObject = jsonObject;
this.jsonKeysIt = jsonObject.keys();
}
代码示例来源:origin: json-path/JsonPath
public Collection<String> getPropertyKeys(Object obj)
{
List<String> keys = new ArrayList<String>(length(obj));
if( obj instanceof org.codehaus.jettison.json.JSONArray )
{
for (int i = 0; i < length(obj); i++)
{
keys.add(String.valueOf(i));
}
}
if( obj instanceof org.codehaus.jettison.json.JSONObject )
{
Iterator<?> keysIt = ((org.codehaus.jettison.json.JSONObject)obj).keys();
while (keysIt.hasNext())
{
keys.add(String.valueOf(keysIt.next()));
}
}
return keys;
}
代码示例来源:origin: com.jayway.jsonpath/json-path
private JettisonObjectIterator(org.codehaus.jettison.json.JSONObject jsonObject)
{
this.jsonObject = jsonObject;
this.jsonKeysIt = jsonObject.keys();
}
代码示例来源:origin: com.sun.jersey/jersey-json
@SuppressWarnings("unchecked")
static <T> Map<String, T> asMap(String jsonObjectVal) throws JSONException {
if (null == jsonObjectVal) {
return null;
}
Map<String, T> result = new HashMap<String, T>();
JSONObject sourceMap = new JSONObject(jsonObjectVal);
Iterator<String> keyIterator = sourceMap.keys();
while (keyIterator.hasNext()) {
String key = keyIterator.next();
result.put(key, (T)sourceMap.get(key));
}
return result;
}
代码示例来源:origin: com.jayway.jsonpath/json-path
public Collection<String> getPropertyKeys(Object obj)
{
List<String> keys = new ArrayList<String>(length(obj));
if( obj instanceof org.codehaus.jettison.json.JSONArray )
{
for (int i = 0; i < length(obj); i++)
{
keys.add(String.valueOf(i));
}
}
if( obj instanceof org.codehaus.jettison.json.JSONObject )
{
Iterator<?> keysIt = ((org.codehaus.jettison.json.JSONObject)obj).keys();
while (keysIt.hasNext())
{
keys.add(String.valueOf(keysIt.next()));
}
}
return keys;
}
代码示例来源:origin: org.codehaus.jettison/jettison
public Node(Node parent, String name, JSONObject object, Convention con)
throws JSONException, XMLStreamException {
this.parent = parent;
this.object = object;
/* Should really use a _Linked_ HashMap to preserve
* ordering (insert order) -- regular one has arbitrary ordering.
* But there are some funky dependencies within unit tests
* that will fail right now, need to investigate that bit more
*/
this.namespaces = new LinkedHashMap();
this.attributes = new LinkedHashMap();
con.processAttributesAndNamespaces(this, object);
keys = object.keys();
this.name = con.createQName(name, this);
}
代码示例来源:origin: org.codehaus.jettison/jettison
Iterator keys = keys();
StringBuilder sb = new StringBuilder("{");
代码示例来源:origin: org.codehaus.jettison/jettison
/**
* Produce a JSONArray containing the names of the elements of this
* JSONObject.
* @return A JSONArray containing the key strings, or null if the JSONObject
* is empty.
*/
public JSONArray names() {
JSONArray ja = new JSONArray();
Iterator keys = keys();
while (keys.hasNext()) {
ja.put(keys.next());
}
return ja.length() == 0 ? null : ja;
}
代码示例来源:origin: org.codehaus.jettison/jettison
public void processAttributesAndNamespaces(Node n, JSONObject object)
throws JSONException, XMLStreamException {
for (Iterator itr = object.keys(); itr.hasNext();) {
String k = (String) itr.next();
for (Iterator pitr = jo.keys(); pitr.hasNext(); ) {
String prefix = (String) pitr.next();
String uri = jo.getString(prefix);
代码示例来源:origin: org.codehaus.jettison/jettison
return "{}";
Iterator keys = keys();
StringBuilder sb = new StringBuilder("{");
int newindent = indent + indentFactor;
代码示例来源:origin: org.codehaus.jettison/jettison
public BadgerFishXMLStreamReader(JSONObject obj)
throws JSONException, XMLStreamException {
String rootName = (String) obj.keys().next();
this.node = new Node(null, rootName, obj.getJSONObject(rootName), CONVENTION);
this.nodes = new FastStack();
nodes.push(node);
event = START_DOCUMENT;
}
代码示例来源:origin: org.codehaus.jettison/jettison
if (hashMapSize == 1) {
dropObjectKeyName = dropRootElement
|| ignoredElements != null && ignoredElements.contains(keys().next());
Iterator keys = keys();
while (keys.hasNext()) {
if (b) {
代码示例来源:origin: org.codehaus.jettison/jettison
public void processAttributesAndNamespaces( Node n, JSONObject object ) throws JSONException {
for (Iterator<?> itr = object.keys(); itr.hasNext();) {
String k = (String) itr.next();
for (Iterator<?> pitr = jo.keys(); pitr.hasNext();) {
代码示例来源:origin: org.codehaus.jettison/jettison
public MappedXMLStreamReader(JSONObject obj, MappedNamespaceConvention con)
throws JSONException, XMLStreamException {
String rootName = (String) obj.keys().next();
this.convention = con;
this.nodes = new FastStack();
this.ctx = con;
Object top = obj.get(rootName);
if (top instanceof JSONObject) {
this.node = new Node(null, rootName, (JSONObject)top, convention);
} else if (top instanceof JSONArray && !(((JSONArray)top).length() == 1 && ((JSONArray)top).get(0).equals(""))) {
this.node = new Node(null, rootName, obj, convention);
} else {
node = new Node(rootName, convention);
convention.processAttributesAndNamespaces(node, obj);
currentValue = JSONObject.NULL.equals(top) ? null : top.toString();
}
nodes.push(node);
event = START_DOCUMENT;
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-p3
@SuppressWarnings("unchecked")
public static Iterator<String> getStringKeys(JSONObject json) {
return json.keys();
}
}
代码示例来源:origin: com.github.lafa.jsonpath/json-path
private JettisonObjectIterator(org.codehaus.jettison.json.JSONObject jsonObject)
{
this.jsonObject = jsonObject;
this.jsonKeysIt = jsonObject.keys();
}
代码示例来源:origin: org.codehaus.jettison/jettison
String theKey = jsonObject.keys().next().toString();
if (lastKey == null || lastKey.equals(theKey)) {
lastKey = theKey;
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
@Override
public Map<String, CimFieldInfo> parse(JSONObject json) throws JSONException {
final Map<String, CimFieldInfo> res = Maps.newHashMapWithExpectedSize(json.length());
final Iterator keysIterator = json.keys();
while (keysIterator.hasNext()) {
final String id = (String) keysIterator.next();
res.put(id, parseIssueFieldInfo(json.getJSONObject(id), id));
}
return res;
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client-core
public Transition parse(JSONObject json) throws JSONException {
final int id = json.getInt("id");
final String name = json.getString("name");
final JSONObject fieldsObj = json.getJSONObject("fields");
final Iterator keys = fieldsObj.keys();
final Collection<Transition.Field> fields = Lists.newArrayList();
while (keys.hasNext()) {
final String fieldId = keys.next().toString();
fields.add(transitionFieldJsonParser.parse(fieldsObj.getJSONObject(fieldId), fieldId));
}
return new Transition(name, id, fields);
}
代码示例来源:origin: com.atlassian.jira/jira-rest-java-client
public Transition parse(JSONObject json) throws JSONException {
final int id = json.getInt("id");
final String name = json.getString("name");
final JSONObject fieldsObj = json.getJSONObject("fields");
final Iterator keys = fieldsObj.keys();
final Collection<Transition.Field> fields = Lists.newArrayList();
while(keys.hasNext()) {
final String fieldId = keys.next().toString();
fields.add(transitionFieldJsonParser.parse(fieldsObj.getJSONObject(fieldId), fieldId));
}
return new Transition(name, id, fields);
}
内容来源于网络,如有侵权,请联系作者删除!