Giter Site home page Giter Site logo

Comments (6)

jeevatkm avatar jeevatkm commented on May 2, 2024 1

You no need to call json.Unmarshal manually. resty does it for you automatically based content type JSON or XML otherwise resty won't do any. Will keep your response body intact.

you might have saw the example, I gave you.

var a  MyStruct
res, err := resty.R().SetResult(&a).Get(....)

// just print it, you will see your values
fmt.Printf("\n%#v\n", res.Result().(*MyStruct))

from resty.

sgon00 avatar sgon00 commented on May 2, 2024 1

Now 2019, the example code above should put in README.md. Without this issue and the code, I have no ideas what to do.

from resty.

jeevatkm avatar jeevatkm commented on May 2, 2024

@miqui Please have a look resty_test.go. You will find more examples.

Automatic marshaling & unmarshalling example:

  1. https://github.com/go-resty/resty/blob/master/resty_test.go#L196
  2. https://github.com/go-resty/resty/blob/master/resty_test.go#L239
  3. https://github.com/go-resty/resty/blob/master/resty_test.go#L331

from resty.

miqui avatar miqui commented on May 2, 2024

@jeevatkm , thanks for the reply,

i am doing this:

res, err := resty.R().Get(....);

 var a  MyStruct
 json.Unmarshal(res.Body(),&a)

so that i can then inspect the a struct properties, ... i was not sure what you meant by "automatic" unmarshalling...

t.Logf("Response Body: %v", resp)
i need to be able to check attributes of the resp JSON

from resty.

miqui avatar miqui commented on May 2, 2024

cool, let me try that...

...it worked thanks!

from resty.

jeevatkm avatar jeevatkm commented on May 2, 2024

I'm glad to hear that. Thanks.

from resty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.