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

Cannot deserialize the current JSON array #18

Open
semihmasat opened this issue Sep 16, 2014 · 5 comments
Open

Cannot deserialize the current JSON array #18

semihmasat opened this issue Sep 16, 2014 · 5 comments

Comments

@semihmasat
Copy link

Hello,

I am new arround here and i tried using SharpSquare. I tried to build a simple app by i am getting this result. ( at the end of the post )

Can you guys help me out ?

Do i need token or something ? How do i do that ?

SharpSquare sharpSquare = new SharpSquare("Client id", "Client secret");

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("ll", "51.508515,-0.1254872");
parameters.Add("categoryId", "4d4b7105d754a06374d81259"); //Food
parameters.Add("radius", "5000");
parameters.Add("limit", "50");
var result = sharpSquare.SearchVenues(parameters);

result.Wait();

ERROR 👍

  •   Thrown: "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'FourSquare.SharpSquare.Entities.FourSquareEntityItems`1[FourSquare.SharpSquare.Entities.Venue]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
    
    To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
    Path 'response.venues', line 1, position 43." (Newtonsoft.Json.JsonSerializationException) Exception Message = "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'FourSquare.SharpSquare.Entities.FourSquareEntityItems`1[FourSquare.SharpSquare.Entities.Venue]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.\r\nPath 'response.venues', line 1, position 43.", Exception Type = "Newtonsoft.Json.JsonSerializationException", Exception WinRT Data = null
@semihmasat semihmasat changed the title WaitingForActivation ? Cannot deserialize the current JSON array Sep 16, 2014
@semihmasat semihmasat reopened this Sep 16, 2014
@vgoloviznin
Copy link

In my case it has to do something with 'what' parameter from 'geocode'. Here's the path from exception:
Path 'response.geocode.what', line 1, position 5573.

@vgoloviznin
Copy link

I've fixed the issue by implementing a new class that is suitable only for getting venues, the class looks like this:

public class FourSquareMultipleVenuesResponse<T> : FourSquareResponse where T : FourSquareEntity
    {
        public VenueResponse<T> response
        {
            get;
            set;
        }
    }

    public class VenueResponse<T>
    {
        public Dictionary<string, object> geocoded
        {
            get;
            set;
        }
        public List<T> venues
        {
            get;
            set;
        }
    }

I've implemented new method GetMultipleVenues<T> which utilizes this class (based on existing GetMultiple method. It's a hack but it's working :)

@EkiFauziFirdaus
Copy link

EkiFauziFirdaus commented Aug 17, 2016

I have same issue here..
Is there any tutorial for search venues?

EDIT:
Yesterday I'm using Sharpsquare from nuget. Now I'm using Sharpsquare from github and it's working. Seems like SharpSquare in nuget isn't updated.

@aykutonen
Copy link

Yes, Github version it`s working but Nuget version had same issue.

@smhlana
Copy link

smhlana commented Oct 17, 2020

I had the same issue with the SharpSquare Nuget package.
I uninstalled it and I downloaded the SharpSquare library from https://github.com/TICLAB/SharpSquare. I opened the project in Visual Studio. It could not find Newtonsoft even though it was installed, so I uninstalled Newtonsoft and installed it again via the Nuget package manager. I then referenced the SharpSquare library in my code and it worked.

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

No branches or pull requests

5 participants