2

This question is a follow up to @joshperry's answer on CustomQueryStringConverter. I implemented this solution with a small modification. My version converts System.Int32[] instead of string[].

However, I have a problem with my WCF configuration. My service dishes out SOAP, XML and JSON. SOAP wasn't a problem, this solution works for XML, but JSON is still messed up. I tried found out that the class that does JSON conversion automatically (enableWebScript behavior) is a sealed class, so I can't override it like you did for WebHttpBehavior. I also tried adding two behaviors, but that didn't work either:

    <behaviors>
      <endpointBehaviors>
        <behavior name="xmlBehavior">          
          <ArrayQuerystring />
        </behavior>
        <behavior name="jsonBehavior">                    
          <ArrayQuerystring />
          <enableWebScript />
        </behavior>
      </endpointBehaviors>      
    </behaviors>

I think it might be an ordering issue? If I put the ArrayQuerystring behavior first, I get no results. If I put it second, then I get the same results as the XML endpoint. How do I apply your CustomQuerystringConverter to a JSON endpoint?

4

1 回答 1

1

JSON 解析器已经支持数组。您可以像这样在 URL 行上传递它们:

...?ID=2&includedCollections=["Addresses","Phones"]
于 2011-02-25T18:00:00.217 回答