I ran up against this problem a number of months ago and posted a somewhat less-than-optimally succinct question here: Configuring WCF data contract for proper JSON response
The problem I had back then turned out to be same as the much more precisely posted question here, in short: within the context of WCF the standard asp.net serialization tools will, for a dictionary, return an ARRAY rather than a key/value pair json OBJECT. I am posting my solution which worked for me although I did resort to using JSON.NET (which I realize the poster was trying to avoid). Nevertheless, maybe this will be helpful to someone.
Function myDictionaryFunction () As Stream Implements IMywebservice.myDictionaryFunction
Dim myKeyValuePairObject As Object = New Dynamic.ExpandoObject
Dim myDictionary = DirectCast(myKeyValuePairObject, IDictionary(Of String, Object))
myDictionary.Add("Test1Key", "Test1Value")
myDictionary.Add("Test2Key", "Test2Value")
myDictionary.Add("Test3Key", "Test3Value")
strJson = JsonConvert.SerializeObject(myKeyValuePairObject)
Dim resultBytes As Byte() = Encoding.UTF8.GetBytes(strJson)
WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"
Return New MemoryStream(resultBytes)
End Function
The result:
{"Test1Key":"Test1Value","Test2Key":"Test2Value","Test3Key":"Test3Value"}
The expando object works like a charm. But to make it work you have to force WCF to return plain text which one would think is easy but it is not. You have to implement a RawContentTypeMapper as suggested here: http://referencesource.microsoft.com/#System.ServiceModel.Web/System/ServiceModel/Channels/RawContentTypeMapper.cs
...And then you have to mess around with your web.config file something like this:
<customBinding>
<binding name="RawReceiveCapable">
<webMessageEncoding
webContentTypeMapperType="myNamespace.RawContentTypeMapper, myLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
</binding>
</customBinding>
I am the first to admit that this solution will likely not receive any awards for elegance. But it worked and returning raw content from a WCF webservice will, if needed, give you some extra control how to serialize your WCF data payload. Since implementing this, I have migrated more and more to ASP.NET Web API (which makes returning RESTful anything much easier than WCF, IMO).