Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.96 KB | None | 0 0
  1. uses
  2.   System.JSON;
  3.  
  4. const
  5.   cJson: string =
  6.     '{"response":{"count":204,"items":[{"id":154770,"body":"","user_id":1,'+
  7.     '"from_id":1,"date":1492002564,"read_state":1,"out":0,"random_id":965793707,'+
  8.     '"fwd_messages":[{"user_id":1,"date":1492002563,"body":"","fwd_messages":'+
  9.     '[{"user_id":1,"date":1492002561,"body":"кек","fwd_messages":[{"user_id":1,'+
  10.     '"date":1492002534,"body":"лол","fwd_messages":[{"user_id":1,"date":'+
  11.     '1492002530,"body":"","fwd_messages":[{"user_id":1,"date":1492002528,'+
  12.     '"body":"","fwd_messages":[{"user_id":1,"date":1492002512,"body":"",'+
  13.     '"fwd_messages":[{"user_id":1,"date":1492002510,"body":"","fwd_messages":'+
  14.     '[{"user_id":1,"date":1492002508,"body":"","fwd_messages":[{"user_id":1,'+
  15.     '"date":1492002506,"body":"","fwd_messages":[{"user_id":1,"date":1492002504,'+
  16.     '"body":"","fwd_messages":[{"user_id":1,"date":1492002499,"body":"",'+
  17.     '"fwd_messages":[{"user_id":1,"date":1492002497,"body":"","fwd_messages"'+
  18.     ':[{"user_id":1,"date":1492002494,"body":"","fwd_messages":[{"user_id":1,'+
  19.     '"date":1492002492,"body":"","fwd_messages":[{"user_id":1,"date":1492002490,'+
  20.     '"body":"","fwd_messages":[{"user_id":1,"date":1492002488,"body":"",'+
  21.     '"fwd_messages":[{"user_id":1,"date":1492002486,"body":"","fwd_messages":'+
  22.     '[{"user_id":1,"date":1491925392,"body":"","fwd_messages":[{"user_id":1,'+
  23.     '"date":1490901947,"body":"test message"}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}]}],'+
  24.     '"in_read":155942,"out_read":155942}}';
  25.  
  26. procedure DoTest;
  27. var
  28.   VStr: string;
  29.   VJsonValue: TJSONValue;
  30.   VJsonObject: TJSONObject;
  31. begin
  32.   VJsonObject := TJSONObject.ParseJSONValue(cJson) as TJSONObject;
  33.   if VJsonObject <> nil then begin
  34.     try
  35.       if VJsonObject.TryGetValue('response["items"]', VJsonValue) then begin
  36.         VStr := VJsonValue.ToJSON;
  37.       end;
  38.     finally
  39.       VJsonObject.Free;
  40.     end;
  41.   end else begin
  42.     // handle json parser error
  43.   end;
  44. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement