我有以下JSON文本.如何可以解析它来获得pageName,pagePic,post_id,等?
{
"pageInfo": {
"pageName": "abc",
"pagePic": "http://example.com/content.jpg"
},
"posts": [
{
"post_id": "123456789012_123456789012",
"actor_id": "1234567890",
"picOfPersonWhoPosted": "http://example.com/photo.jpg",
"nameOfPersonWhoPosted": "Jane Doe",
"message": "Sounds cool. Can't wait to see it!",
"likesCount": "2",
"comments": [],
"timeOfPost": "1234567890"
}
]
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码尝试读取属性文件:
Properties prop = new Properties();
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream stream = loader.getResourceAsStream("myProp.properties");
prop.load(stream);
Run Code Online (Sandbox Code Playgroud)
我在最后一行得到一个例外.特别:
Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:418)
at java.util.Properties.load0(Properties.java:337)
at java.util.Properties.load(Properties.java:325)
at Assignment1.BaseStation.readPropertyFile(BaseStation.java:46)
at Assignment1.BaseStation.main(BaseStation.java:87)
Run Code Online (Sandbox Code Playgroud)
谢谢,尼科斯
我打算开发一个小型(Java)应用程序来管理我的财务状况.我相信我需要使用嵌入式数据库,但我对此问题没有经验.我试着看一些可用的产品,但我无法决定哪一种更适合我.H2,HSQLDB,Derby和Berkeley DB似乎都是不错的候选者,但我仍然看不出他们如何相互比较.感谢您帮助我们比较它们并帮助我决定使用哪一个.
我打算在我的应用程序中使用Hibernate(除非你建议使用DBMS提供的API),但我也希望能够使用SQL浏览工具(修改模式和更改数据)轻松编辑数据库.
谢谢.
我有一个对象,其中包含一些我想序列化的不可序列化的字段.它们来自我无法更改的单独API,因此将它们设置为Serializable不是一种选择.主要问题是Location类.它包含四个可以序列化的东西,我需要它们,所有的内容.如何使用read/writeObject创建可执行以下操作的自定义序列化方法:
// writeObject:
List<Integer> loc = new ArrayList<Integer>();
loc.add(location.x);
loc.add(location.y);
loc.add(location.z);
loc.add(location.uid);
// ... serialization code
// readObject:
List<Integer> loc = deserialize(); // Replace with real deserialization
location = new Location(loc.get(0), loc.get(1), loc.get(2), loc.get(3));
// ... more code
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?