Quantcast
Channel: Sarina DuPont, Product Manager RAD Studio
Viewing all articles
Browse latest Browse all 132

Visualizing json data with LiveBindings

$
0
0

In RAD Studio XE6, we introduced support for Backend as a Service (BaaS) providers with components for Kinvey and Parse.

If you want to see the raw json data that you are sending/receiving with push notifications, you can enable it using the LiveBindings Designer. In this example, I am binding the PushEvents1.JSONResult property to the Memo1.Text property.

Any time I send a notification to my app (based on the instructions in this blog post), I will see the raw json data returned in my Memo. This is very useful for seeing what json you are sending and receiving.

If you wanted to do the same in code, you would setup the following OnPushReceived event for TPushEvents. You also need to add JSON.Rest to the uses clause:

procedure TForm29.PushEvents1PushReceived(Sender: TObject;

const AData: TPushData);

var

LJSON: TJSONObject;

begin

LJSON := TJSONObject.Create;

// Build JSON representation of push data

AData.GCM.Save(LJSON, ‘gps’);

AData.APS.Save(LJSON, ‘aps’);

AData.Extras.Save(LJSON, ‘extras’);

AData.SaveMessage(LJSON, ‘message’);

// Format JSON and append to memo

Memo1.Lines.Add(TJson.Format(LJSON));

LJSON.Free;

end;

Regards,

Sarina


Viewing all articles
Browse latest Browse all 132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>