简体   繁体   中英

Json Hijacking Restsharp. modify response content before deserialization.

Ok. So I'm trying to use Restsharp as a Http Client.

Basicaly I need to modify a response content before deserialization.

Is there a point of extension where I could do this?

You know what I mean?

Form API I, get valid json answer but with ")]}'," ( hijacking prevention) as a prefix.

Now I need to remove it. Is there a way to do that?

Weel I think I figure it out.

I have to execute result first and then Deserializer class that i have derived from JsonDeserializer;

var reult = client.Execute(request);
            var u  = new MyDeserializer().Deserialize<UserGuamInformations>(reult);

and part of the class:

   public new  T Deserialize<T>(IRestResponse response){
        string str = response.Content;
        response.Content = str.Remove(0, 6);//remove )]}',\n
        return base.Deserialize<T>(response);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM