以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- josn 结构[ ] (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=108400) |
-- 作者:fubblyc -- 发布时间:2017/10/22 8:51:00 -- josn 结构[ ] 老师,如下问题: Dim url As String = "https://api.weixin.qq.com/card/create?access_token={0}" Dim hc As New HttpClient(CExp(url,Functions.Execute("GetAccessToken"))) Dim jo As New JObject Dim ja As New JArray jo("card") = New JObject() jo("card")("card_type") = "GENERAL_COUPON" jo("card")("general_coupon") = New JObject() jo("card")("general_coupon")("base_info") = New JObject() jo("card")("general_coupon")("base_info")("brand_name") = "AAA" jo("card")("general_coupon")("base_info")("title") = title jo("card")("general_coupon")("Advanced_info") = New JObject() 下面这一段不懂的怎么写: \'jo("card")("general_coupon")("Advanced_info")("time_limit") = New JObject() Dim ar As New JArray \'For i As Integer = 1 To 1 \'可以有多段图文 Dim ao As New JObject ao("type") = "monday" ao("begin_hour") = 10 ao("end_hour") = 22 ao("begin_minute") = 01 ao("end_minute") = 30 ar.add(ao) \'Next jo("card")("general_coupon")("Advanced_info")("time_limit") = ar 微信文档是这样: { "card": { "card_type": "GROUPON", "groupon": { "base_info": { "brand_name": "微信餐厅", "title": "132元双人火锅套餐", }, "advanced_info": { "time_limit": [ { "type": "MONDAY", "begin_hour":0, "end_hour":10, "begin_minute":10, "end_minute":59 }, { "type": "HOLIDAY" } ], }, } } } |
-- 作者:有点甜 -- 发布时间:2017/10/22 18:39:00 -- 1、直接循环不就行了?比如
For i As Integer = 1 To 2 \'可以有多段图文
2、你也可以写多段下面的代码
Dim ao As New JObject |
-- 作者:fubblyc -- 发布时间:2017/10/22 22:28:00 -- 恩恩。 甜老师,好像这句不对 jo("card")("general_coupon")("Advanced_info")("time_limit") = ar
|
-- 作者:有点甜 -- 发布时间:2017/10/22 22:59:00 -- 怎么不对,合成的json有什么差异?报什么错? |
-- 作者:fubblyc -- 发布时间:2017/10/22 23:21:00 -- 甜老师,提示说数据格式有误 我的代码: Dim url As String = "https://api.weixin.qq.com/card/create?access_token={0}" Dim hc As New HttpClient(CExp(url,Functions.Execute("GetAccessToken"))) Dim jo As New JObject Dim ja As New JArray jo("card") = New JObject() jo("card")("card_type") = "GENERAL_COUPON" jo("card")("general_coupon") = New JObject() jo("card")("general_coupon")("base_info") = New JObject() jo("card")("general_coupon")("base_info")("title") = title jo("card")("general_coupon")("Advanced_info") = New JObject() Dim ar As New JArray Dim ao As New JObject ao("type") = "monday" ao("begin_hour") = 10 ao("end_hour") = 22 ao("begin_minute") = 01 ao("end_minute") = 30 ar.add(ao) jo("card")("general_coupon")("Advanced_info")("time_limit") = ar jo("card")("general_coupon")("default_detail") = default_detail hc.Content = jo.ToString() jo = JObject.Parse(hc.GetData) [此贴子已经被作者于2017/10/22 23:22:54编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/10/23 9:43:00 -- 试试照抄,如果还不行,询问一下微信客服。
Dim jo As New JObject
|
-- 作者:fubblyc -- 发布时间:2017/10/23 15:11:00 -- 甜老师,我看了json,和文档是一模一样。不知道为什么。 { "card": { "card_type": "GENERAL_COUPON", "general_coupon": { "base_info": { "brand_name": "aa", "can_share": true, "can_give_friend": true, "use_all_locations": true }, "advanced_info": { "time_limit": [ { "type": "Monday", "begin_hour": 10, "end_hour": 22, "begin_minute": 1, "end_minute": 30 }, { "type": "HOLIDAY" } ] }, "default_detail": "1.6折卡,不超过3件 \\r\\n2.全场通用" } } } 微信文档: https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025056
|
-- 作者:有点甜 -- 发布时间:2017/10/23 15:33:00 -- 1、你的json是参考哪里的?文档没有你那样的json
2、要求的那些必填字段,你都没有包含进来
https://mp.weixin.qq.com/debug/
|
-- 作者:fubblyc -- 发布时间:2017/10/23 16:18:00 -- 额,甜老师,你是说 "base_info": { "brand_name": "aa", "can_share": true, "can_give_friend": true, "use_all_locations": true }, 这个中间我是省略了,是可以正常创建卡券。 我这里只体现了这一段,加了这一段就不行。。。 "advanced_info": { "time_limit": [ { "type": "Monday", "begin_hour": 10, "end_hour": 22, "begin_minute": 1, "end_minute": 30 }, { "type": "HOLIDAY" } ] }, |
-- 作者:fubblyc -- 发布时间:2017/10/23 16:52:00 -- 我写上完整的: { "card": { "card_type": "GENERAL_COUPON", "general_coupon": { "base_info": { "logo_url": "http://mmbiz.qpic.cn/mmbiz_jpg/ahyj0ppmibfrFYMKPQWAknRVZ4QgJJia8NXOEFeflPTxLmwCPEfRXg2wibzVuGtaLpn7CyRlc9P1mfiblLbnnr5y2A/0", "brand_name": "三木", "code_type": "CODE_TYPE_ONLY_BARCODE", "title": "1650", "color": "Color010", "notice": "使用时向服务员出示此券", "service_phone": "11", "description": "1.不可与其他优惠共享 2.一张小票使用一张券 3.", "date_info": { "type": "DATE_TYPE_FIX_TIME_RANGE", "begin_timestamp": 1508198400, "end_timestamp": 1509408000 }, "sku": { "quantity": 0 }, "get_limit": "1000", "use_limit": "1", "use_custom_code": true, "get_custom_code_mode": "GET_CUSTOM_CODE_MODE_DEPOSIT", "bind_openid": false, "can_share": true, "can_give_friend": true, "use_all_locations": true }, "advanced_info": { "time_limit": [ { "type": "Monday", "begin_hour": 10, "end_hour": 22, "begin_minute": 1, "end_minute": 30 }, { "type": "HOLIDAY" } ] }, "default_detail": "1.6折卡,不超过3件 2.全场通用" } } } [此贴子已经被作者于2017/10/23 16:55:00编辑过]
|