Exception is thrown in JSON parser ParseString (char[] json, ref int index, ref bool success) #39

Open
opened 2015-05-20 07:24:46 -07:00 by romansavrulin · 2 comments
romansavrulin commented 2015-05-20 07:24:46 -07:00 (Migrated from github.com)

The function in lib/JSON.cs:193 protected static string ParseString (char[] json, ref int index, ref bool success)
throws an exception "The argument must not be in surrogate pair range" in lib/JSON.cs:244 s.Append (Char.ConvertFromUtf32 ((int)codePoint)); that is not handled by (tested on instagram API, media/popular endpoint). If you assume JSON API return status code via bool argument, this exception must be handled.

I've muted it with

try{
  // convert the integer codepoint to a unicode char and add to string
  s.Append (Char.ConvertFromUtf32 ((int)codePoint));
}catch(Exception e){
  s.Append ( "" );
}

it works, but i'm not sure if it is correct logic.

The function in lib/JSON.cs:193 `protected static string ParseString (char[] json, ref int index, ref bool success)` throws an exception "The argument must not be in surrogate pair range" in lib/JSON.cs:244 `s.Append (Char.ConvertFromUtf32 ((int)codePoint));` that is not handled by (tested on instagram API, `media/popular` endpoint). If you assume JSON API return status code via bool argument, this exception must be handled. I've muted it with ``` charp try{ // convert the integer codepoint to a unicode char and add to string s.Append (Char.ConvertFromUtf32 ((int)codePoint)); }catch(Exception e){ s.Append ( "" ); } ``` it works, but i'm not sure if it is correct logic.
andyburke commented 2015-05-21 11:51:03 -07:00 (Migrated from github.com)

Can you add some example JSON that causes this exception to throw?

Can you add some example JSON that causes this exception to throw?
romansavrulin commented 2015-05-22 07:05:44 -07:00 (Migrated from github.com)

try this one (remove .jpg from filename)
blow json

In spite of the cause of exception, it must be handled internally in this function.

try this one (remove .jpg from filename) ![blow json](https://cloud.githubusercontent.com/assets/1313542/7772066/77a1013c-00a4-11e5-888f-eb096c05f6e5.jpg) In spite of the cause of exception, it must be handled internally in this function.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
andyburke/UnityHTTP#39
No description provided.