Configuring WCF data contract for proper JSON response

前端 未结 2 1238
囚心锁ツ
囚心锁ツ 2021-01-24 23:26

I manage a number of Bed & Breakfast websites and run a kind of booking engine to help the client do bookings directly on their website (as opposed to going to another site

2条回答
  •  抹茶落季
    2021-01-25 00:22

    In your sample of the "proper" json, room_types is not a collection property. In json format, collections are enclosed with [ ], as you have it in your second "wrong" sample. That means that your room_types is in fact an object having two properties "Orchid Room" and "Presidential Suite". Note that the property name with the space is achievable by setting the Name property of the DataMember Attribute:

提交回复
热议问题