JsonTextReader buffer size

Jun 12, 2013 at 9:13 AM
Hello;

I use JsonTextReader class to read my json, but I am having a concern with the size of the buffer variable : char [] _chars = new char [1025]) why limit reading at 1025 characters, because my json file have more than 2000 characters.

Can you make this dynamic in a future release ?
or offer a better solution than recompiling with char [] _chars = new char [4096];

thank you.

Moi123
Coordinator
Jun 14, 2013 at 2:40 AM
Why are you worried about more than one read of characters into the buffer?
Jun 14, 2013 at 8:43 AM
I have a problem because when I do read () to move forward in my reading, he stops to 1025 characters, it will never read until the end of the document Json response Get from my HTTP request.

exemple :
 public static Object readEntity(StreamReader content)
 {
            if (content == null ) { // void response
                return null;
            }
          
            JsonTextReader reader = new JsonTextReader(content);
            reader.Read();

            /*.....*/
          return readDocument(reader);
}


 public static Document readDocument(JsonTextReader jt)
        {
            String uid = null;
            String path = null;
            String type= null;
            jt.Read();
            JsonToken tok = jt.TokenType;
            while (tok != JsonToken.EndObject) 
            {
                if(jt.Value != null)
                {
                    String key = jt.Value.ToString();
                    jt.Read();
                    tok = jt.TokenType;
                    if (key.Equals("uid")) 
                    {
                        uid = jt.Value.ToString();
                    }
                   else if (key.Equals("path")) 
                    {
                        if(jt.Value == null)
                        {
                             path ="null";
                        }
                        else
                        {
                            path =jt.Value.ToString();
                        }
                    } else if (key.Equals("type")) 
                    {
                        if(jt.Value == null)
                        {
                            type ="null";
                        }
                        else
                        {
                            type =jt.Value.ToString();
                        }
                  }
                     /* .......*/
                jt.Read();
                tok = jt.TokenType;
                }
            return new Document(uid, type, path);