Coldfusion REST-CFC的序列化数组

Coldfusion REST-CFC的序列化数组,rest,serialization,coldfusion,cfc,coldfusion-10,Rest,Serialization,Coldfusion,Cfc,Coldfusion 10,嗨,我正在尝试从我的一个REST端点序列化CFC数组。我在Adobe帮助中发现了这一点,这正是我想要做的(如果必要,我可以发布一些代码),但当我尝试使用returnType=“myCFC[]”时,它失败了: “消息”:“数组元素类型不匹配” 奇怪的是,如果我实例化同一个对象并从.cfm文件中调用该方法,那么cfdump会按预期显示包含数据的对象数组。但是从我的AJAX调用来看,对象的属性值都是空的。但是,如果我使用returnserializeJSON(myArrayOfCFCs)属性就有数据。

嗨,我正在尝试从我的一个REST端点序列化CFC数组。我在Adobe帮助中发现了这一点,这正是我想要做的(如果必要,我可以发布一些代码),但当我尝试使用
returnType=“myCFC[]”
时,它失败了:

“消息”:“数组元素类型不匹配”

奇怪的是,如果我实例化同一个对象并从.cfm文件中调用该方法,那么cfdump会按预期显示包含数据的对象数组。但是从我的AJAX调用来看,对象的属性值都是空的。但是,如果我使用return
serializeJSON(myArrayOfCFCs)
属性就有数据。但我不想这样做,因为这将否定内容协商的使用

我只是好奇是否有人能让它起作用

更新:

 <cffunction name="getPatient" access="remote" httpmethod="GET" returntype="Patient[]" produces="text/json" restpath="/{PatientId}">
    <cfargument name="PatientId" type="numeric" required="true" restargsource="Path" />

    <cfset local.response = ArrayNew(1) />
    <cfset local.patient = getPatientGatewayObject().getPatient(PatientId)>

    <cfset local.patientObject = createObject("component", "Patient").init(argumentCollection=queryRowToStruct(local.patient)) />
    <cfset arrayAppend(local.response, local.patientObject) />

    <cfreturn local.response />

 </cffunction>

这是可行的,但不是我最终想要的:

 <cffunction name="getPatient" access="remote" httpmethod="GET" returntype="Patient" produces="text/json" restpath="/{PatientId}">
    <cfargument name="PatientId" type="numeric" required="true" restargsource="Path" />

    <cfset local.response = ArrayNew(1) />
    <cfset local.patient = getPatientGatewayObject().getPatient(PatientId)>

    <cfset local.patientObject = createObject("component", "Patient").init(argumentCollection=queryRowToStruct(local.patient)) />
    <cfset arrayAppend(local.response, local.patientObject) />

    <cfreturn serializeJSON(local.response) />

 </cffunction>

请发布您尝试过的内容