RestDataSource: not interpreting JSON string ?

DataSource definition…

		DataSource ds = new RestDataSource( );
            ds.setDataURL("xxx/yyy/zzz") ;
	ds.setDataTransport(RPCTransport.XMLHTTPREQUEST);
	ds.setDataFormat(DSDataFormat.JSON);

		//class java.lang.Long
		DataSourceIntegerField partyId = new DataSourceIntegerField("partyId");
		partyId.setPrimaryKey(true);

		ds.addField(partyId);

		//class java.lang.String
		DataSourceTextField imageURL = new DataSourceTextField("imageURL");
		ds.addField(imageURL);

		//class java.lang.String
		DataSourceTextField homepage = new DataSourceTextField("homepage");
		ds.addField(homepage);

		//class java.lang.String
		DataSourceTextField name = new DataSourceTextField("name");
		ds.addField(name);

		//class java.util.Date
		DataSourceDateField modified = new DataSourceDateField("modified");
		modified.setUseTextField(true) ;
		ds.addField(modified);

		//class java.util.Date
		DataSourceDateField created = new DataSourceDateField("created");
		created.setUseTextField(true) ;
		ds.addField(created);

		//interface com.secondporch.core.model.Party
		DataSourceTextField modifiedBy = new DataSourceTextField("modifiedBy");
		ds.addField(modifiedBy);

		//interface com.secondporch.core.model.Party
		DataSourceTextField createdBy = new DataSourceTextField("createdBy");
		ds.addField(createdBy);

transformResponse:
@Override
protected void transformResponse(DSResponse response,
DSRequest request, Object data) {
super.transformResponse(response, request, data);

System.err.println( "request=" + request.getHttpMethod() + " " + request.getActionURL() ) ;
System.err.println( "response=" + response.getHttpResponseCode() + " " + data ) ;
System.err.println( "data length=" +response.getData().length ) ;	

 this.data = response.getData() ; 
 }

response from server:
[{“partyId”:“1”,“created”:null,“homepage”:null,“imageURL”:null,“modified”:null,“name”:“brian”,“createdBy_partyId”:null,“modifiedBy_partyId”:null}]

but DataSource does not think there is any data ?
request=null null
response=200 [object Object]
data length=0

In order to load the data, I had to jump through some pretty unexpected hoops.

	@Override
	protected void transformResponse(DSResponse response, DSRequest request,
			Object data) {
		super.transformResponse(response, request, data);
   	        final JavaScriptObject jso = (JavaScriptObject) data;
		final int arrayLength = JSOHelper.arrayLength(jso);
		final ListGridRecord[] records = new ListGridRecord[arrayLength];
		if (arrayLength > 0) {
			for (int i = 0; i < arrayLength; i++) {
				final JavaScriptObject obj = (JavaScriptObject) JSOHelper
						.arrayGetObject(jso, i);
				records[i] = new ListGridRecord(obj);
			}
		}
		response.setData(records);
	}

RestDataSource provides a simple protocol for interacting with the server for situations where you do not already have a pre-existing protocol in place. If you simply fulfill the documented message formats for RestDataSource, no transformResponse() overrides or similar customizations are required.

If you are trying to adapt to a pre-existing format, it’s better to start from DataSource rather than RestDataSource, as, again, RestDataSource is preconfigured to expect the particular protocol shown in the documentation and examples. In particular, your original attempt failed because RestDataSource has default settings for recordXPath, which are shown in the docs.

A thorough read of the documentation will lead to many fewer “unexpected” behaviors.