這是我的圖"seriesType": { "code": "83001", "$": "Série" }
如何解析json與json jackson?我無法這樣做,因爲美元符號會產生錯誤。如何使用Json Jackson解析帶有特殊字符註釋的JSON圖形?
我想這
public Dollar serieType;
public class Dollar {
public int code;
public String $;
}
// is is the input stream
jp = jsonFactory.createJsonParser(is);
serieType = objectMapper.readValue(jp, Dollar.class);
strBuffer.append("serieType: " + dollar.$ + "\n");
//這是一些怎麼樣我試過,我相信這個問題是由美元符號引起的。
我試圖讓這樣String s=tvseries.serieType.$
的值,這是堆棧跟蹤01-02 10:48:03.905: W/ActivityManager(58): Launch timeout has expired, giving up wake lock! 01-02 10:48:04.623: W/ActivityManager(58): Activity idle timeout for HistoryRecord{5b799e28 com.test.jackson/.MainAlloCine} 01-02 10:48:07.886: W/System.err(275): java.lang.NullPointerException 01-02 10:48:07.895: W/System.err(275): at com.test.jackson.MainAlloCine.onCreate(MainAlloCine.java:49) 01-02 10:48:07.895: W/System.err(275): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 01-02 10:48:07.895: W/System.err(275): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 01-02 10:48:07.895: W/System.err(275): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 01-02 10:48:07.895: W/System.err(275): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 01-02 10:48:07.895: W/System.err(275): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 01-02 10:48:07.895: W/System.err(275): at android.os.Handler.dispatchMessage(Handler.java:99) 01-02 10:48:07.895: W/System.err(275): at android.os.Looper.loop(Looper.java:123) 01-02 10:48:07.895: W/System.err(275): at android.app.ActivityThread.main(ActivityThread.java:4627) 01-02 10:48:07.895: W/System.err(275): at java.lang.reflect.Method.invokeNative(Native Method) 01-02 10:48:07.895: W/System.err(275): at java.lang.reflect.Method.invoke(Method.java:521) 01-02 10:48:07.905: W/System.err(275): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 01-02 10:48:07.905: W/System.err(275): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 01-02 10:48:07.905: W/System.err(275): at dalvik.system.NativeStart.main(Native Method)
謝謝你,但它仍然無法讀取值:'( – Vervatovskis 2011-12-29 23:22:37
那麼是什麼問題?異常,缺少值或什麼?順便說一下,你的結構是錯誤的:它必須匹配 – StaxMan 2011-12-30 01:09:12
應用程序崩潰時,他閱讀「$」,我相信100%的結構是正確的,我總是使用json和parser。這是你可以看一下的圖形,[graph](http://api.allocine.fr/rest/v3/ tvseries?partner = YW5kcm9pZC12M3M&code = 223&profile = large&mediafmt = mp4-lc&format = json&striptags = synopsis,synopsisshort) – Vervatovskis 2011-12-30 15:07:16