dziwna dziwna - 1 month ago 20
C# Question

Newtonsoft.Json.JsonReaderException: Unterminated string. Expected delimiter

I receive this exception during parsing string containing JSON:

Newtonsoft.Json.JsonReaderException: Unterminated string. Expected delimiter: ". Path '[114].var2', line 1, position 431602.


So I went to exactly that (431602) position and found that it's here:
(...)lZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqK*jp*KWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW1(...)

So it's just simply "jp" chars which shouldn't be anything wrong.

What could be a reason for this exception?

EDIT
To be more specific I also put a whole string with few variables around it:

"var1":"946","var2":"\/9j\/4AAQSkZJRgABAQAAAQABAAD\/\/gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gNjAK\/9sAQwANCQoLCggNCwoLDg4NDxMgFRMSEhMnHB4XIC4pMTAuKS0sMzpKPjM2RjcsLUBXQUZMTlJTUjI+WmFaUGBKUVJP\/9sAQwEODg4TERMmFRUmTzUtNU9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09P\/8AAEQgAeABHAwEiAAIRAQMRAf\/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC\/\/EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29\/j5+v\/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC\/\/EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoK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gE8Y9SazIfCUCNi5upH9kUL\/PNdZ411S60ia3e3ijdLhSpLg8Ffoff9K8+udc1i7lKwswz2hj\/wAmuKca7k7OyNouCWqOpt9A0mFMm3Lkd3cn\/wCtT2uNF0\/7rWkLDsoG79Oa5BNL1q95m8zB7zSf061p6d4OmnuESa5XJONsa5\/U1g6Uft1LlqT6RO18OXUWsXLSW6u1tbEZkYYDP2A+nX8q6qqek6bb6Tp0VlajCRjknqx7k1crvpUo0o2iYSk5O7CiiitSQooooAoavaLc26ExLI0ThgCufY\/zrEOi39xIf3ccMeeNx7fQUUVzzoRqTvIuM3FaFqLw1ggy3ZI7hEx+pP8AStOy0u2sm3xb2fGNznOKKKuNGnHVITnJ7su0UUVqSJRmiigAzRRRQB\/\/2Q==","var3":"77241"

Answer

I noticed that this seems to be a base64 encoded JPEG. In most cases it would be better & easier to have your server send back the jpeg rather than JSON.

public ActionResult ShowImage() 
{
    var file = Server.MapPath("~/App_Data/UserUpload/asd.png");
    return File(file, "image/png", Path.GetFileName(file));
}

To see original source follow this link.