I've got this query:
SELECT name, (SELECT From__c, To__c FROM Trip__r) FROM Account limit 1
[ { "attributes" : { "type" : "Account", "url" : "/services/data/v29.0/sobjects/Account/001b000000HZ" }, "Name" : "Adam II", "Trip__r" : { "totalSize" : 2, "done" : true, "records" : [ { "attributes" : { "type" : "Trip__c", "url" : "/services/data/v29.0/sobjects/Trip__c/a00b000000AOj" }, "To__c" : "2013-11-27T15:15:00.000+0000", "Id" : "a00b000000AOj", "Car__c" : "001b000000HZ", "From__c" : "2013-11-25T15:15:00.000+0000" }, { "attributes" : { "type" : "Trip__c", "url" : "/services/data/v29.0/sobjects/Trip__c/a00b000000A" }, "To__c" : "2013-11-28T20:58:00.000+0000", "Id" : "a00b000000AOlR", "Car__c" : "001b000000HZp", "From__c" : "2013-11-27T20:58:00.000+0000" } ] }, "Id" : "001b000000HZp" } ]
But, I need to get rid this part
"Trip__r" : { "totalSize" : 2, "done" : true,
So it looks like
[ { "attributes" : { "type" : "Account", "url" : "/services/data/v29.0/sobjects/Account/001b000000HZ" }, "Name" : "Adam II", "records" : [ { "attributes" : { "type" : "Trip_c", "url" : "/services/data/v29.0/sobjects/Trip_c/a00b000000AOj" }, "To_c" : "2013-11-27T15:15:00.000+0000", "Id" : "a00b000000AOj", "Car_c" : "001b000000HZ", "From_c" : "2013-11-25T15:15:00.000+0000" }, { "attributes" : { "type" : "Trip_c", "url" : "/services/data/v29.0/sobjects/Trip_c/a00b000000A" }, "To_c" : "2013-11-28T20:58:00.000+0000", "Id" : "a00b000000AOlR", "Car_c" : "001b000000HZp", "From_c" : "2013-11-27T20:58:00.000+0000" } ], "Id" : "001b000000HZp" } ]
I tried to look around wrappers, deserialisations, but still can't understand them! Any help would be very appreciated!
List<Account> accounts = [SELECT name, (SELECT From_c, To_c FROM Trip__r) FROM Account limit 1];
return JSON.serializePretty(accounts)