Additional text encountered after finished reading JSON content:

When parsing through json you may encounter the error “Additional text encountered after finished reading JSON content:”. This is usually due to incorrect json syntax.

One such example that result in the above error would be

{"StaffID":"S01","StaffRank":"Manager"},{"StaffID":"S02","StaffRank":"Waiter"}

Surrounding the above with square brackets which denotes that it’s an array will solve the problem.
[{"StaffID":"S01","StaffRank":"Manager"},{"StaffID":"S02","StaffRank":"Waiter"}]

However when you do the above, you will be required to deserialize it as an array of object otherwise the following error will occur. “Cannot deserialize the current JSON array (e.g. [1,2,3]) into type ‘tbl_Staff’ because the type requires a JSON object (e.g.{“name”:”value”}) to deserialize correctly”

Advertisements
This entry was posted in C#, Json and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s