Can't use libjson because of compile error

Help
capjdcoder
2013-03-28
2014-03-20
  • capjdcoder

    capjdcoder - 2013-03-28

    Last days I downloaded the libjson and need to use it for my C++ project. But when I tried to run a test program - I got an error

      

     main.cpp:7:36: No viable conversion from 'basic_string<char, char_traits<char>, allocator<char>>' to 'const basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t>>'
    

    The sample code is here:
     
        #include "libjson/libjson.h"
        #include <string>
       
     

      int main()
        {
            std::string json = "{\"RootA\":\"Value in parent node\",\"ChildNode\":{\"ChildA\":\"String Value\",\"ChildB\":42}}";
            JSONNode node = libjson::parse(json);
            return 0;
        }
    

    Can anyone tell me what am I doing wrong?

     
  • capjdcoder

    capjdcoder - 2013-03-28

    Sorry forgot to mention, that error is at this point:

    JSONNode node = libjson::parse(json);
    
     
  • Warren Tucker

    Warren Tucker - 2014-03-20

    try this JSONNode node = libjson::parse(json.c_str()); the parse funciton requires a char string c_str is a const char and will do the job for you that is what I have done. Can't explain the difference as I am still learning myself use this it's been quite good for me. http://www.youtube.com/user/MissouriSandTCourses

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks