1

I am getting StackOverflowException when I try to run following linq query on following JSON object. It is observed that when the static function enclosing this query executed at the first time it runs well. But the next time it gives the error.

Exception message

An unhandled exception of type 'System.StackOverflowException' occurred in System.Core.dll

Here is the query

IEnumerable<long> iDs = = from p in jObject["response"]["docs"]
                              select Convert.ToInt64((string)p["id"]);

Here is the JSON object

{
  "responseHeader": {
    "status": 0,
    "QTime": 4,
    "params": {
      "sort": "noofsales desc, score desc",
      "fl": "id",
      "indent": "false",
      "start": "0",
      "q": "texttags:baby romper  bodysuit jumpsuit unisex boy girl animal costume sizes clothes deal offer\r\ndealtitle:baby romper  bodysuit jumpsuit unisex boy girl animal costume sizes clothes deal offer\r\nwhatyouget:baby romper  bodysuit jumpsuit unisex boy girl animal costume sizes clothes deal offer\r\nalltags:baby romper  bodysuit jumpsuit unisex boy girl animal costume sizes clothes deal offer\r\ndealdescription:baby romper  bodysuit jumpsuit unisex boy girl animal costume sizes clothes deal offer^80\r\ndealcity:National",
      "wt": "json",
      "fq": [
        "dealendtime:[NOW TO NOW+100YEAR]",
        "IF alltags: Experiences THEN dealcity:national National ELSE dealcity:national",
        "soldout:0"
      ],
      "rows": "24"
    }
  },
  "response": {
    "numFound": 35,
    "start": 0,
    "docs": [
      {
        "id": "787"
      },
      {
        "id": "23867"
      },
      {
        "id": "920"
      },
      {
        "id": "22768"
      },
      {
        "id": "1018"
      },
      {
        "id": "695"
      },
      {
        "id": "22890"
      },
      {
        "id": "23866"
      },
      {
        "id": "22741"
      },
      {
        "id": "1654"
      },
      {
        "id": "22975"
      },
      {
        "id": "23870"
      },
      {
        "id": "972"
      },
      {
        "id": "974"
      },
      {
        "id": "12379"
      },
      {
        "id": "12201"
      },
      {
        "id": "12199"
      },
      {
        "id": "1261"
      },
      {
        "id": "12205"
      },
      {
        "id": "12198"
      },
      {
        "id": "12191"
      },
      {
        "id": "12209"
      },
      {
        "id": "22919"
      },
      {
        "id": "12203"
      }
    ]
  }
}
2
  • try changing the query to foreach loop and breakdown the conversion states to multiple lines with casting to string and then converting to int and finding expected vs obtained value. Commented Oct 9, 2013 at 5:38
  • possible duplicate of LINQ query creates a StackOverflow Exception Commented Jan 29, 2014 at 18:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.