Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The func httpx.Parse Data struct have a UnmarshalJsonReader's Bug, can't parse []map[string]string structure type. #2684

Closed
bmomhan opened this issue Dec 9, 2022 · 4 comments · Fixed by #2693
Assignees

Comments

@bmomhan
Copy link

bmomhan commented Dec 9, 2022

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is
    test.http
###
#用户申请退款消息 SPI
POST http://localhost:8888/test
Content-Type: application/json

{
  "order_id": "1234567",
  "refund_reason": {
    "reason_code": [
      123,
      234
    ],
    "desc": "不想要了",
    "show_reason": [
      {
        "123": "货品不足",
        "234": "已经打烊"
      }
    ]
  },
  "product_detail": {
    "product_id": "123",
    "sku_id": "123",
    "name": "小蛋糕",
    "actual_amount": 100
  }
}

###

test_entity.go

type OrderApplyRefundReq struct {
 OrderId       string            `json:"order_id"`
 RefundReason  RefundReasonData  `json:"refund_reason,optional"`
 ProductDetail ProductDetailData `json:"product_detail,optional"`
}

type RefundReasonData struct {
 ReasonCode []int               `json:"reason_code"`
 Desc       string              `json:"desc"`
 ShowReason []map[string]string `json:"show_reason"`
}

type ProductDetailData struct {
 ProductId    string `json:"product_id"`
 SkuId        string `json:"sku_id"`
 Name         string `json:"name"`
 ActualAmount int    `json:"actual_amount"`
}
  1. The error is

metrics:
unreadable: protocol error E08 during memory read for packet $m83486f7610663b49,5...
container:
unreadable: could not read string len protocol error E08 during memory read for packet $m4868246c894870ec,4...


**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environments (please complete the following information):**
- OS: [e.g. macOs]
- go-zero version [e.g. 1.3.5]
- goctl version [e.g. 1.3.8, optional]

**More description**
Add any other context about the problem here.
@bmomhan
Copy link
Author

bmomhan commented Dec 9, 2022

change []map[string]string to []map[string]interface{} , parse can pass

@smithyj
Copy link
Contributor

smithyj commented Dec 10, 2022

confirm that the question,mapping.unmarshaler parse bug,use json.Unmarshal is ok

@smithyj
Copy link
Contributor

smithyj commented Dec 10, 2022

@kevwan

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@kevwan

@kevwan kevwan self-assigned this Dec 10, 2022
kevwan added a commit to kevwan/go-zero that referenced this issue Dec 12, 2022
@kevwan kevwan linked a pull request Dec 12, 2022 that will close this issue
kevwan added a commit that referenced this issue Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants