Question: Basically what I want to do is to load a string from a file that is to be encoded as a json. 

The way I have achieved this is quite verbose for what should be a simple operation:

```
std::ifstream t(json_path);

std::string stringbuf = std::string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());

boost::erase_all(stringbuf, "\t");

boost::erase_all(stringbuf, "\n");

boost::erase_all(stringbuf, " ");

```

Is there a briefer way to load a text file to a string and strip out the special characters?

Answer: 
You can use `std::getline` and erase/remove idiom with a lambda (or functor, if you don't have C++11 support), like

```
std::string string_buf(std::istreambuf_iterator<char>(t), {});
string_buf.erase(std::remove_if(string_buf.begin(), string_buf.end(), 
        [](char c) { return std::isspace(c);}), 
        string_buf.end()
);

```
```
// Open the file
std::ifstream t(json_path);

// Initialize the string directly, no = sign needed.
// C++11: Let second istreambuf_iterator argument be deduced from the first.
std::string stringbuf(std::istreambuf_iterator<char>(t),  {});

// C++11: Use a lambda to adapt remove_if.
char ws[] = " \t\n";
auto new_end = std::remove_if( stringbuf.begin(), stringbuf.end(),
    []( char c ) { return std::count( ws, ws + 3, c ); } );

// Boost was doing this part for you, but it's easy enough.
stringbuf.erase( new_end, stringbuf.end() );

```