使用枚举数据类型发送JSON

时间:2017-07-06 19:45:12

标签: java java-ee enums ebay ebay-api

我正在尝试根据ebay文档发送一个数据类型为枚举的json:

http://developer.ebay.com/devzone/rest/api-ref/inventory/types/OperatingHours.html

有问题的字段是dayOfWeekEnum,我尝试以多种方式发送JSON:

{"dayOfWeekEnum": "FRIDAY"}
{"dayOfWeekEnum": 0}
{"dayOfWeekEnum": {"dayOfWeekEnum": "FRIDAY"}}

他们都没有工作。我alwyas得到消息说它无法序列化字段dayOfWeekEnum

[{"errorId"=>2004, "domain"=>"ACCESS", "category"=>"REQUEST", "message"=>"Invalid request", "longMessage"=>"The request has errors. For help, see the documentation for this API.", "parameters"=>[{"name"=>"reason", "value"=>"Could not serialize field [operatingHours.dayOfWeekEnum]"}]}] 

我假设ebay运行Java api,那么我应该如何正确发送我的JSON枚举信息呢?

1 个答案:

答案 0 :(得分:1)

我从经验中知道,就字段名称而言,eBay的文档可能是错误的。您是否尝试过 dayOfWeek 而不是dayOfWeekEnum?