Shevek
Shevek

Reputation: 4063

How to get Flurl to ignore JSON hijack prevention

I am trying to consume a JSON API using Flurl

If I use .GetStringAsync() the API returns as follows:

{} && {identifier:'ID', label:'As at 15-11-2018 6:25 PM',items:[...]}

However, when I try .GetJsonAsync<MyObj>() the properties are all null, I assume because of the {} &&.

Is there any way to force Flurl to ignore this and use the actual JSON data, or do I have to use .GetStringAsync(), manually remove the {} && and deserialize?

Upvotes: 0

Views: 554

Answers (1)

Shevek
Shevek

Reputation: 4063

It doesn't look like there is an inbuilt way to do this with Flurl so my workaround is to use Flurl's string method, manipulate the string, then use Newtonsoft to deserialize:

var response = await url.GetStringAsync();

if (!string.IsNullOrEmpty(response))
{
    response = response.Replace("{}&&", "");

    var feed = JsonConvert.DeserializeObject<MyObj>(response);

    ...do stuff...

}

Upvotes: 1

Related Questions