Java json lib
Java json lib
¸ù¾Ýhttp://www.javaeye.com/topic/561368̸µ½µÄÒ»¸öjacksonµÄjsonÐòÁл¯¹¤¾ßÐÔÄܱÈjson-libµÈÒªºÃ
ÎÞÂÛÊÇÔڵͲ¢·¢»¹ÊǸ߲¢·¢µÄÇé¿öÏ£¬Ê±¼äÐÔÄÜÉÏ£¬jacksonʹÓÃÖØÓÃObjectMapper·½Ê½´ó´óÓÅÓÚʹÓÃjson-lib·½Ê½£¬ÉõÓÚjacksonʹÓ÷ÇÖØÓÃObjectMapper·½Ê½Ò²ÂÔÓÅÓÚjson-lib·½Ê½¡£ÁíÍâÒ²¿ÉÒÔ¿´³ö£¬jacksonÔÚÖØÓÃObjectMapperµÄ·½Ê½Ï£¬ÐÔÄܼ¸ºõ½Ó½üÓÚÖ±½ÓʹÓÃStringBufferµÄappend·½·¨½øÐÐ×Ö·û´®Æ´½ÓÁË£¬ÓÈÆäÔڸ߲¢·¢µÄÇé¿öÏ£¬Á½ÕßµÄÇúÏß¼¸ºõÒªÖغÏÁË¡£´ÓÕâÀï¿ÉÒÔ¿´³öjacksonµÄÐÔÄܷdz£³öÉ«¡£
jacksonûÓÐÏñjson-libÒ»ÑùµÄxml--jsonÖ®¼äÖ±½Óת»»µÄ¹¦ÄÜ
gson±ÈjacksonÂýÒ»¸öÊýÁ¿¼¶,¶øÇÒgsonÊǶÔfieldÐòÁл¯,²»·ûºÏjava bean¹ßÀý¶ÔgetterÐòÁл¯.
ÎÒ¸Õ¸Õ´ÖÂÔ²âÊÔÁËһϣ¬Ò»¸ö¸´ÔÓ¶ÔÏóÐòÁл¯1000´Î£¬ÎÒÓÃjackson»¨ÁË6.5ms£¬¶øÓÃgson»¨ÁË65ms×óÓÒ
json-libÓëstruts2´øµÄjson²å¼þÏà±ÈÒ²ÒªÂý30%£¬ÐÔÄÜȷʵһ°ã¡£
xstreamÐòÁл¯Ò²¶ÔjavabeanµÄ¹æ·¶Ö§³Ö²»ºÃ£¬²»ÊǸù¾Ýget·½·¨À´µÄ£¬ÊǸù¾ÝÊôÐÔÀ´µÄ¡£
http://jackson.codehaus.org/Tutorial
http://jackson.codehaus.org/Home
It support following features:
Streaming API is best performing (lowest overhead, fastest read/write; other 2 methods build on it)
Data Binding is often most convenient
Tree Model is most flexible
Ïà¹ØÎĵµ£º
JavaÖÐÒì³£Ò»°ã·ÖΪ3À࣬ϱ߽éÉÜÏ£¬½ö½öÊǸöÈËÀí½â¡£
µÚÒ»ÖÖÊDZàÒëÆÚÒì³££¬»òÕß½Ðcheck Exception¡£
±àÒëÆÚÒì³£µÄÌص㣺
1.ϵͳҪÇó±ØÐëÔÚ³ÌÐòÀï×ö³ö´¦Àí£¬·ñÔò±¨±àÒë´íÎ󣬱àÒëÎÞ·¨Í¨¹ý£¬Ò²¾ÍÊÇ˵ϵͳǿÖÆÒªÇó´¦Àí£¬¶ÔÓÚ´¦Àí·½Ê½£¬²»ÍâºõÖ±½Ócatch´¦ÀíºÍÅ׳öµ½Íâ²ã£¬µ«ÊÇ×îÖÕ»¹ÊÇÒª´¦ÀíµÄ¡£
2.Óû§×Ô¶¨ÒåÒ»¸ö±àÒëÆÚÒ ......
1.»ù±¾¸ÅÄîµÄÀí½â
¡¡¡¡¾ø¶Ô·¾¶£º¾ø¶Ô·¾¶¾ÍÊÇÄãµÄÖ÷Ò³ÉϵÄÎļþ»òĿ¼ÔÚÓ²ÅÌÉÏÕæÕýµÄ·¾¶£¬(URLºÍÎïÀí·¾¶)ÀýÈ磺
C:\xyz\test.txt ´ú±íÁËtest.txtÎļþµÄ¾ø¶Ô·¾¶¡£http://www.sun.com/index.htmÒ²´ú±íÁËÒ»¸ö
URL¾ø¶Ô·¾¶¡£
¡¡¡¡Ïà¶Ô·¾¶£ºÏà¶ÔÓëij¸ö»ù׼Ŀ¼µÄ·¾¶¡£°üº¬WebµÄÏà¶Ô·¾¶£¨HTMLÖеÄÏà¶ÔĿ¼£©£¬ÀýÈ磺ÔÚ
......
Öµ´«µÝ£º·½·¨µ÷ÓÃʱ£¬Êµ¼Ê²ÎÊý°ÑËüµÄÖµ´«µÝ¸ø¶ÔÓ¦µÄÐÎʽ²ÎÊý£¬·½·¨Ö´ÐÐÖÐÐÎʽ²ÎÊýÖµµÄ¸Ä±ä²»Ó°Ïìʵ¼Ê²Î ÊýµÄÖµ¡£
"ÒýÓô«µÝ"£ºÒ²³ÆΪ´«µØÖ·¡£·½·¨µ÷ÓÃʱ£¬Êµ¼Ê²ÎÊýµÄÒýÓÃ(µØÖ·£¬¶ø²»ÊDzÎÊýµÄÖµ)±»´«µÝ¸ø·½·¨ÖÐÏà¶ÔÓ¦µÄÐÎʽ²ÎÊý£¬ÔÚ·½·¨Ö´ÐÐÖУ¬¶ÔÐÎʽ²ÎÊýµÄ²Ù×÷ʵ¼ÊÉϾÍÊǶÔʵ¼Ê²ÎÊýµÄ²Ù×÷£¬·½·¨Ö´ÐÐÖÐÐÎʽ²ÎÊýÖµµÄ¸Ä ......