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

JSON request body whose root starts with an array fails to match with JsonPath/JsonPartial as matcher #895

Closed
cvadityaflipkart opened this issue Jan 31, 2020 · 1 comment
Labels

Comments

@cvadityaflipkart
Copy link
Contributor

cvadityaflipkart commented Jan 31, 2020

Description of the bug

JSON request body whose root starts with an array fails to match with JsonPath as matcher.

Steps to reproduce the issue

Any http request with the following body
https://jsonplaceholder.typicode.com/posts

and the simulation file containing the following matcher

        "body" : [ {
          "matcher" : "JsonPath",
          "value" : "$[0]"
        } ]

Edit: It also occurs with JsonPartial

        "body" : [ {
          "matcher" : "jsonpartial",
          "value" : "{\"userId\": 1}"
        } ]

Observed result

Hoverfly error messages seen (If none, say none)

Failed to unmarshal body to JSON: json: cannot unmarshal array into Go value of type map[string]interface {}

If possible, add screenshots to help explain your problem

Expected result

No error

Additional relevant information

  1. Hoverfly version: 1.1.3
  2. Schema Version: v5
  3. Probable fix at
    var data map[string]interface{}
@cvadityaflipkart cvadityaflipkart changed the title JSON request body whose root starts with an array fails to match with JsonPath as matcher JSON request body whose root starts with an array fails to match with JsonPath/JsonPartial as matcher Jan 31, 2020
cvadityaflipkart added a commit to cvadityaflipkart/hoverfly that referenced this issue Jan 31, 2020
cvadityaflipkart added a commit to cvadityaflipkart/hoverfly that referenced this issue Jan 31, 2020
@tommysitu tommysitu added the bug label Jan 31, 2020
tommysitu pushed a commit that referenced this issue Feb 3, 2020
@tommysitu
Copy link
Member

fixed in v1.1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants