我有以下JSON:
{
"registration": {
"name": "Vik Kumar",
"first_name": "Vik",
"last_name": "Kumar",
"bloodGroup": "B-",
"gender": "male",
"birthday": "10\/31\/1983",
"email": "vik.ceo\u0040gmail.com",
"cellPhone": "1234123456",
"homePhone": "1234123457",
"officePhone": "1234123458",
"primaryAddress": "jdfjfgj",
"area": "jfdjdfj",
"location": {
"name": "Redwood Shores, California",
"id": 103107903062719
},
"subscribe": true,
"eyePledge": false,
"reference": "fgfgfgfg"
}
}
Run Code Online (Sandbox Code Playgroud)
我使用以下代码来解析它:
JsonNode json = new ObjectMapper().readTree(jsonString);
JsonNode registration_fields = json.get("registration");
Iterator<String> fieldNames = registration_fields.getFieldNames();
while(fieldNames.hasNext()){
String fieldName = fieldNames.next();
String fieldValue = registration_fields.get(fieldName).asText();
System.out.println(fieldName+" : "+fieldValue);
}
Run Code Online (Sandbox Code Playgroud)
这工作正常,它打印除了位置的所有值,这是另一层嵌套.我尝试了与上面的代码相同的技巧来传递json.get("location"),但这不起作用.请建议如何使其适用于位置.
基于如何使用xpointer与Xinclude引用元素 ...
当命名空间urn包含多个冒号时,我遇到了包括使用xpointer的嵌套元素的问题.
Test1.xml
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="urn:some:namespace">
<element1 id="001">
<element2 id="001.1" order="1">
<element3 id="001.1.1"/>
</element2>
<element2 id="001.2" order="2">
<lement3 id="001.1.2"/>
</element2>
</element1>
</Root>
Run Code Online (Sandbox Code Playgroud)
Test2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Root>
<element1 id="999">
<element2 id="999.1" order="1">
<element3 id="999.1.1"/>
</element2>
</element1>
</Root>
Run Code Online (Sandbox Code Playgroud)
的merge.xml
<?xml version="1.0"?>
<Root xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="Test1.xml" xpointer="xmlns(ns=urn:some:namespace)xpointer(/ns:Root/ns:element1)" parse="xml" />
<xi:include href="Test2.xml" xpointer="xpointer(//Root/element1)" parse="xml" />
</Root>
Run Code Online (Sandbox Code Playgroud)
命令:
xmllint --pretty 1 --xinclude Merge.xml
错误
Merge.xml:5: element include: XInclude error : XPointer evaluation failed: #xmlns(ns=urn:some:namespace)xpointer(/ns:Root/ns:element1)
Merge.xml:5: element include: XInclude error : …
Run Code Online (Sandbox Code Playgroud) 我正在编写一个gradle插件,希望从应用此插件的项目的资源中读取特定的属性文件.要读取这些资源,我需要一个项目的类路径.目前我要去:
org.gradle.api.Project.getBuildscript().getClassLoader().getResourcesAsStream(...)
Run Code Online (Sandbox Code Playgroud)
但即使该项目中存在此类资源,它也始终返回null.
这是我的general.xml
档案
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
<item
android:id="@+id/next"
android:title="Next"
android:visible="true"
android:enabled="true"
android:showAsAction="always"
android:orderInCategory="1">
</item>
<item
android:id="@+id/Previous"
android:title="Previous"
android:visible="true"
android:enabled="true"
android:orderInCategory="2"
android:showAsAction="always">
</item>
<item android:id="@+id/star"
android:icon="@drawable/ic_action_important"
android:enabled="true"
android:orderInCategory="0"
android:showAsAction="always"
android:title="Star"
android:visible="true">
</item>
</menu>
Run Code Online (Sandbox Code Playgroud)
这是我的代码
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.general, menu);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#003f84")));
return true;
}
Run Code Online (Sandbox Code Playgroud)
现在,我的问题是菜单项没有显示在操作栏中.我在这里做错了吗?
android android-appcompat android-actionbar android-support-library