Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8122137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:44:01+00:00 2026-06-06T05:44:01+00:00

My QT-based single-threaded console app running on Linux parses JSON strings using Boost, and

  • 0

My QT-based single-threaded console app running on Linux parses JSON strings using Boost, and it works fine ordinarily, except when receiving very large chunks of JSON. I have a piece of valid JSON around 160kb in size (!) and when I attempt to parse it, the call to Boost’s JSON parser never returns. I’ve left it a considerable time. If I subsequently break in using the debugger, my app is idly sitting in its message loop, as though nothing happened. The call throws no exceptions. There’s nothing noteworthy about the JSON except for its large size – it’s well-formed and entirely composed of ASCII characters.

How can execution simply “give up” and return to the QT message loop?

void IncomingRequestHandler::OnRequest(const QString& message)
{
    try
    {
        std::stringstream ss;
        ss << message.toStdString();
        boost::property_tree::ptree requestObject;

        cout << "Before read_json" << endl;  // Gets here
        boost::property_tree::json_parser::read_json(ss, requestObject);
        cout << "After read_json" << endl;  // Never gets here

        // ... Some other code ...
    }
    catch (const boost::property_tree::json_parser::json_parser_error& e)
    {
        cout << "Invalid JSON" << endl;  // Never gets here
    }
    catch (const std::runtime_error& e)
    {
        cout << "Invalid JSON" << endl;  // Never gets here
    }
    catch (...)
    {
        cout << "Invalid JSON" << endl;  // Never gets here
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:44:02+00:00Added an answer on June 6, 2026 at 5:44 am

    First, I agree with two comments above: try to minimize your program.

    Second, I would try to check whether Qt (stl, boost, this particular version of whatever) can handle strings that large. Make sure your parser is getting the whole string.

    Third, I would use ostringstream rather than sstream. 🙂

    According to boost documentation, it seems that the only way the parser returns an error is by returning error information in your property_tree. If it continues reading forever, it probably means that it’s reading garbage beyond the actual JSON data and gets stuck on it.

    Finally, read_json can accept the file name, so why bother with reading the file and creating a stream? Why don’t you try this:

        boost::property_tree::ptree requestObject;
        cout << "Before read_json" << endl;  // Gets here
        boost::property_tree::json_parser::read_json(jsonFileName.toStdString(),
                                                     requestObject);
        cout << "After read_json" << endl;  // Never gets here
    

    I’ve just performed a little test with JSON file 400Kb big, and it works just fine:

        #include <iostream> 
        #include <string> 
        #include <boost/property_tree/ptree.hpp>
        #include <boost/property_tree/json_parser.hpp>
    
        using namespace std;
    
        int main(int argc, char* argv[])
        {
            string infname = argv[1];
    
            boost::property_tree::ptree requestObject;
            cout << "Before read_json" << endl;  // Gets here
            boost::property_tree::json_parser::read_json(infname, requestObject);
            cout << "After read_json" << endl;  // Works fine
    
            return 0;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using a github repository with a single branch, based of a master
My Delphi XE application is based on a single EXE using a local server
I am using below query to count a particular column data based on single
I'm using the Showtime wordpress theme which builds a blog based on a single
Non-forking (aka single-threaded or select() -based) webservers like lighttpd or nginx are gaining in
My iPhone app (based on the Single View Application of Xcode) has a UITextView
Assuming a JavaScript-based single-page application is returned by the server on the initial request.
A supplier uses Ping Federate for SAML-based single sign-on. I've got some custom SAML
I am working on an asp.net web site that is based upon a single
I have a number of build definitions that get executed based upon a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.