XMLパーサーだと日本語をデコードしてくれる
上のJSONパーサーだと日本語を作ってくれないのですが、
XMLだとどうかと思って実験してみました。
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="385" height="108"> <fx:Script> <![CDATA[ import com.adobe.serialization.json.JSON; protected function button1_clickHandler(event:MouseEvent):void { var str:String='<?xml version="1.0" encoding="UTF-8"?><hash><status>succeed</status><message>ログインしました</message></hash>'; var xml:XML=new XML(str); trace(xml.message); label.text=xml.message; } ]]> </fx:Script> <fx:Declarations> <!-- 非ビジュアルエレメント (サービス、値オブジェクトなど) をここに配置 --> </fx:Declarations> <s:Button x="10" y="10" label="変換" click="button1_clickHandler(event)"/> <s:Label x="10" y="39" fontSize="12" id="label"/> </s:WindowedApplication>
JSON JSONしているのはRuby on Rails関係だけで、
世の中的にはまだまだ普通はXMLだろ。って
ことなのかもしれません。
個人的にはJSONでいきたいんだけどな。
読みやすいし。短いし。