-
2015-11-21 貓空茶香環狀步道半日遊
又到了周末步道遊的時間了,因為之前在健行筆記看到的新聞,所以這次就是它啦!
先來張導覽圖,圖是連到上面說的那則新聞裡的導覽圖。
Read more… -
Duplicated JSON Properties After Serialize with Jackson
Following problem found in the previous post, certain property got duplicated in the JSON after serialized polymorphic objects with Jackson.
According to this article, Jackson will output
action
property based on the value of@JsonSubTypes.Type
, and then serialize the object. Sinceaction
property is used for polymorphic object deserialization and as an actual member of the class,action
get duplicated.The solution is simple and can be found in the same artitle. Just change
Read more…JsonTypeInfo.As.PROPERTY
in@JsonTypeInfo
toJsonTypeInfo.As.EXISTING_PROPERTY
. -
Jackson 序列化後的 JSON 出現重複的屬性
接續之前的文章,發現 Polymorphic 物件序列化後,用來判斷物件類別的屬性被重複輸出了兩次。
根據這篇文章的說法,Jackson 在續列化時會根據
@JsonSubTypes.Type
的值先輸出action
屬性,接著才把物件內容序列化。碰巧該物件也有一個action
屬性,所以被輸出了兩次。會發生這樣的問題是因為action
被同時用來判斷物件類別以及其他用途。要解決很簡單,同一篇文章就有答案了。把
Read more…@JsonTypeInfo
裡的JsonTypeInfo.As.PROPERTY
改成JsonTypeInfo.As.EXISTING_PROPERTY
即可。如下 -
Deserialize JSON Into Polymorphic Types With Jackson
Problem
Assume you have two types of JSON documents, and the following actions depend on the value of specific attribute.
{ "action": "login", "userId": "xxx" }
{ "action": "sendMessage", "message": "user Message" }
The simplest way is to deserialized them into Map, but that would be very not object-oriented. We need to find a way to automatically deserialize them into right type of objects.
Read more… -
用 Jackson 將 JSON 反序列化成 Polymorphic 物件
問題
假設有兩種下列的 JSON 文件,依特定屬性的值決定該文件的作用:
{ "action": "login", "userId": "xxx" }
{ "action": "sendMessage", "message": "user Message" }
假如兩種 JSON 文件都有可能收到,最簡單的方法就是都轉成 Map,但是這樣就很不物件化,這時候就需要一種方法可以自動判斷並反序列化成對應的物件。
Read more… -
Handshake failed due to invalid Upgrade header: null
昨天用 Chrome 的 Simple WebSocket Client 測試用 Spring Framework 開發的 WebSocket 程式時,發現一直吐出
Read more…org.springframework.web.socket.server.support.DefaultHandshakeHandler.handleInvalidUpgradeHeader Handshake failed due to invalid Upgrade header: null
的錯誤訊息。但是用 Wireshark 抓封包看到送出的 Request 其實是有Upgrade: websocket
。 -
重新出發
公司把 Tumblr 擋掉了,反正那邊也太久沒用了,上次用發覺很慢,就乾脆換個地方重新出發吧。 這次改用 JBake 加上 Github Page,所有東西都可以版本控制,就玩玩看吧。
-
Linux 掛載 Windows 網芳
安裝
apt-get install smbclient apt-get install cifs-utils
瀏覽
smbclient -L //IP/Share -U domain/username -D subdirectory
掛載
mount -t cifs -o user=<username>,domain=<domain>,password=<password> //IP/Share/subdirectory /mount_point
-
「回到明朝當王爺」觀後感
打個分數:四顆星
拜網路和 Kindle 的幫助,在幾乎睜開眼有時間的情況下就是拿來看回到明朝當王爺。就算是這樣也花了半個月以上的時間,真的是很長的一本小說。
簡單來說,就是男主角陰錯陽差的回到了明朝附身在一個邊疆的秀才身上,又很強運的在兩三年內一路狂升,從邊疆的驛丞、太子侍讀、神機營參將、內廠廠督、威武侯、威武公直至威武王。又運用了一些現代人的知識和身旁高手的協助,鬥倒掉了劉謹、開海禁、滅倭寇海盜、驅夷人收復滿刺加、平四川蠻族叛亂、平白巾賊響馬盜內亂,連蒙古韃靼也被他解決了,最後還封疆蒙古準備北上吃掉西伯利亞。過程中還一路取了嬌妻美妾,這還不夠強運嗎!
Read more… -
2011-07 日月潭兩天一夜
六月初經由李小淮得知了南投縣魚池鄉『日月潭頭社休閒農業區』自行車逍遙遊的活動,再加上好心人贊助的日月潭湖景房,所以 7⁄2 就往南投出發啦!
第一站是埔里酒廠,天氣很熱。首先就買了好像大家一定會的買紹興香腸,一支才 $25,不貴也不錯吃啦!
Read more…