Line is too long RRS feed

  • Question

  • User1115113499 posted

    Hi, I have Json return from an API.  Based on my search, it returns 400 results. BUT when I try to add this to my script to deserialize it (after 17 result), it gives me this error:

    Line is too long.

    What would be the remedy for this issue.  I tried stringbuilder but it is a hassle.

    any help?

    Thursday, March 16, 2017 4:26 PM


All replies

  • User753101303 posted


    I'm not 100% sure to get what you mean with "add this to my script". For now my understanding is that this is a JavaScript side error. If you meant you just process these results, could it be that you have a programming logic error causing to create a single huge JavaScript string ?

    Then you talked about StringBuilder? Could it be t a server side C# exception instead ? (and maybe for the same reason ie you try to create a huge string probably because of some programming error)

    Thursday, March 16, 2017 4:43 PM
  • User1115113499 posted

    Sorry about the confusion.

    Basically, The string that I get from this API is too long.  I am doing this is VB:

    dim jsonString2 as string ="{'results': [ { 'name1':'name one', 'rating1':'1'},{ 'name2':'name two', 'rating2':'2'}, ..........................]}"   // this is sting is very very long

    Dim json As JObject = JObject.Parse(jsonString.ToString & jsonString2.ToString)

            Dim commToken As JToken
            Dim commValue As String
            For Each Row In json("results").ToList()
                commToken = Row("rating")
                commValue = DirectCast(commToken, JValue).Value
                Response.Write(commValue & "<br>")

    and I get "Line is too big" when I compile this.


    Thursday, March 16, 2017 6:50 PM
  • User753101303 posted

    Ok so it seems to be a compile time because the literal string is too long. You could try http://stackoverflow.com/questions/18510247/how-to-specify-long-string-literals-in-visual-basic-net

    You could also store that in a file and use System.IO.File.ReadAllText to read this string from a file.

    Edit: or if it is really hardcoded data you could initialize directly a data structure and query this structure rather than deserializing from a literal string ?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 16, 2017 7:15 PM
  • User1115113499 posted

    Thanks PatriceSC,  System.IO.File.ReadAllText worked just fine

    Thursday, March 16, 2017 7:43 PM