Menu

Writing without using the reader

2008-05-28
2013-04-22
  • Shadi Ibrahem

    Shadi Ibrahem - 2008-05-28

    Hi,

    I'm trying to use the styled writer in order to create an document,
    I haven't seen a code that builds a root without using the reader,
    Can I build the root - (Value variable) and initiate it and then use the writer? (without using the reader.parse or at all)

    if so can you provide a sample code for building a root for:
    {
      key : val
    }

    thanx

     
    • Al Vega

      Al Vega - 2008-11-26

      Hello,

      I read the jsoncpp API and wrote a sample code, that creates a json array and populates with string values; then all data is dumped into `fpath` filename.

      See also src/jsontestrunner/main.cpp

      int write_test_array_22(int limit)
      {
          char buf[20];
          Json::Value root(Json::arrayValue);
          for (int i=0; i<limit; i++) {
              sprintf(buf, "%09d", i);
              root.append(Json::Value(buf));
          }

          std::string fpath = "test_array_22.json";
          std::string rewrite;
          return rewriteValueTree(fpath, root, rewrite);
      }

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.