开发者

how to use httpservice to request&response json data from mobile(client) to server in flash builder 4.5?

开发者 https://www.devze.com 2023-03-23 05:41 出处:网络
Firstly i share my code that it is right. [Bindable] private var myArrayCollection:ArrayCollection; private function serviceSend():void

Firstly i share my code that it is right.

how to use httpservice to request&response json data from mobile(client) to server in flash builder 4.5?

[Bindable]
        private var myArrayCollection:ArrayCollection;

private function serviceSend():void
        {
            var header:Object = new Object();
            header["Accept"] = "application/json";

            loginService.headers = header;
            loginService.contentType = "application/json";
            loginService.send()
        }

private function initRequest():String
        {
            jsonStr = '{"loginRequest":{"userId":"300002918","password":"ibnkcn13","language":"zh_CN"},"requestHeader":{"clientContext":{"country":"CN","channel":"IPHONE","userName":"iphoneuser","password":"password"},"serviceContext":{"serviceId":"serviceId","token":"","nonce":""},"userContext":{"userId":"sdffff","sessionId":"fsdfsdf","language":"zh_CN"}}}';       

            return jsonStr;
        }

private function onJSONResult():void
        {
             responseData = loginService.lastResult.toString();

            //loginService.resultFormat.toString();

            //responseData = responseData.replace( /\s/g, ''); 

            txt.visible=true;
            txt.text=responseData;
            trace(responseData);

            //var jd:JSONDecoder = new JSONDecoder( responseData , false);

            var obj:Object = JSON.decode(responseData);


            //var arr:Array = (JSON.decode(responseData) as Array);
            myArrayCollection = new ArrayCollection;

            var obj1:Object = new Object;
            obj1.customerName1 = obj.loginResponse.login.customerName1;
            obj1.customerName2 = obj.loginResponse.login.customerName2;


            myArrayCollection.addItem(obj1);

        }

<s:Panel visible="true" width="100%" height="100%"
                 title="HTTPService">
            <s:DataGrid id="dgPosts1" width="100%" height="100%"
                        dataProvider="{myArrayCollection}">
                <s:columns>
                        开发者_如何学运维<s:ArrayList>
                            <s:GridColumn dataField="customerName2"
                                          headerText="customerName2"/>
                            <s:GridColumn dataField="customerName1"
                                          headerText="customerName1"/>
                    </s:ArrayList>
                </s:columns>
            </s:DataGrid>
        </s:Panel> 

Then, i want to know how to parse every value of json data in a easy way ? i want to parse these json data like this and how to do

how to use httpservice to request&response json data from mobile(client) to server in flash builder 4.5?

just like:

var jd:JSONDecoder = new JSONDecoder( responseData , false);
dgPosts1.dataProvider = jd as ArrayCollection;

<s:DataGrid id="dgPosts1" width="100%" height="100%"
                        dataProvider="{myArrayCollection}">
                <s:columns>
                    <json:JSONDecoder>
                        <json:id>
                                                       ...................
                        </json:id>
                    </json:JSONDecoder>

the code is failed. i want to know how to use the in datagrid to parse the json dataprovider? thanks a lot.

0

精彩评论

暂无评论...
验证码 换一张
取 消