Git Product home page Git Product logo

jzon's People

Contributors

cmorse avatar lexicality avatar smart--petea avatar zguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jzon's Issues

Compilation Error with Example

I am getting this compilation error with g++. And my main.cpp is the example for this link: http://code.google.com/p/jzon/wiki/WritingFiles

My g++ version output is:

macbook-pro:Jzon v2-0 will$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

g++ -Wall -I. jsonWriterMain.cpp Jzon.cpp -o jsonWriter
In file included from jsonWriterMain.cpp:4:
Jzon.h:42: error: expected class-name before ‘{’ token
Jzon.h: In constructor ‘Jzon::TypeException::TypeException()’:
Jzon.h:44: error: expected class-name before ‘(’ token
Jzon.h: At global scope:
Jzon.h:48: error: expected class-name before ‘{’ token
Jzon.h: In constructor ‘Jzon::ValueException::ValueException()’:
Jzon.h:50: error: expected class-name before ‘(’ token
Jzon.h: At global scope:
Jzon.h:54: error: expected class-name before ‘{’ token
Jzon.h: In constructor ‘Jzon::NotFoundException::NotFoundException()’:
Jzon.h:56: error: expected class-name before ‘(’ token
Jzon.h: In member function ‘virtual bool Jzon::Node::Has(const std::string&) const’:
Jzon.h:110: warning: statement has no effect
Jzon.h: In member function ‘virtual Jzon::Node& Jzon::Node::Get(const std::string&) const’:
Jzon.h:112: warning: statement has no effect
Jzon.h: In member function ‘virtual Jzon::Node& Jzon::Node::Get(size_t) const’:
Jzon.h:113: warning: statement has no effect
/usr/include/c++/4.2.1/bits/stl_pair.h: At global scope:
/usr/include/c++/4.2.1/bits/stl_pair.h: In instantiation of ‘std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>’:
Jzon.h:208: instantiated from here
/usr/include/c++/4.2.1/bits/stl_pair.h:84: error: forming reference to reference type ‘Jzon::Node&’
Jzon.h: In member function ‘Jzon::NamedNode Jzon::Object::iterator::operator_()’:
Jzon.h:208: error: no matching function for call to ‘std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(std::basic_string<char, std::char_traits, std::allocator >&, Jzon::Node&)’
/usr/include/c++/4.2.1/bits/stl_pair.h:80: note: candidates are: std::pair<_T1, _T2>::pair() [with _T1 = std::basic_string<char, std::char_traits, std::allocator >, T2 = Jzon::Node&]
/usr/include/c++/4.2.1/bits/stl_pair.h:69: note: std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(const std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>&)
Jzon.h: In member function ‘const Jzon::NamedNode Jzon::Object::const_iterator::operator
()’:
Jzon.h:225: error: no matching function for call to ‘std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(const std::basic_string<char, std::char_traits, std::allocator >&, Jzon::Node&)’
/usr/include/c++/4.2.1/bits/stl_pair.h:80: note: candidates are: std::pair<_T1, _T2>::pair() [with _T1 = std::basic_string<char, std::char_traits, std::allocator >, T2 = Jzon::Node&]
/usr/include/c++/4.2.1/bits/stl_pair.h:69: note: std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(const std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>&)
In file included from Jzon.cpp:22:
Jzon.h:42: error: expected class-name before ‘{’ token
Jzon.h: In constructor ‘Jzon::TypeException::TypeException()’:
Jzon.h:44: error: expected class-name before ‘(’ token
Jzon.h: At global scope:
Jzon.h:48: error: expected class-name before ‘{’ token
Jzon.h: In constructor ‘Jzon::ValueException::ValueException()’:
Jzon.h:50: error: expected class-name before ‘(’ token
Jzon.h: At global scope:
Jzon.h:54: error: expected class-name before ‘{’ token
Jzon.h: In constructor ‘Jzon::NotFoundException::NotFoundException()’:
Jzon.h:56: error: expected class-name before ‘(’ token
Jzon.h: In member function ‘virtual bool Jzon::Node::Has(const std::string&) const’:
Jzon.h:110: warning: statement has no effect
Jzon.h: In member function ‘virtual Jzon::Node& Jzon::Node::Get(const std::string&) const’:
Jzon.h:112: warning: statement has no effect
Jzon.h: In member function ‘virtual Jzon::Node& Jzon::Node::Get(size_t) const’:
Jzon.h:113: warning: statement has no effect
/usr/include/c++/4.2.1/bits/stl_pair.h: At global scope:
/usr/include/c++/4.2.1/bits/stl_pair.h: In instantiation of ‘std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>’:
Jzon.h:208: instantiated from here
/usr/include/c++/4.2.1/bits/stl_pair.h:84: error: forming reference to reference type ‘Jzon::Node&’
Jzon.h: In member function ‘Jzon::NamedNode Jzon::Object::iterator::operator
()’:
Jzon.h:208: error: no matching function for call to ‘std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(std::basic_string<char, std::char_traits, std::allocator >&, Jzon::Node&)’
/usr/include/c++/4.2.1/bits/stl_pair.h:80: note: candidates are: std::pair<_T1, _T2>::pair() [with _T1 = std::basic_string<char, std::char_traits, std::allocator >, T2 = Jzon::Node&]
/usr/include/c++/4.2.1/bits/stl_pair.h:69: note: std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(const std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>&)
Jzon.h: In member function ‘const Jzon::NamedNode Jzon::Object::const_iterator::operator
()’:
Jzon.h:225: error: no matching function for call to ‘std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(const std::basic_string<char, std::char_traits, std::allocator >&, Jzon::Node&)’
/usr/include/c++/4.2.1/bits/stl_pair.h:80: note: candidates are: std::pair<_T1, _T2>::pair() [with _T1 = std::basic_string<char, std::char_traits, std::allocator >, _T2 = Jzon::Node&]
/usr/include/c++/4.2.1/bits/stl_pair.h:69: note: std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>::pair(const std::pair<std::basic_string<char, std::char_traits, std::allocator >, Jzon::Node&>&)
Jzon.h: In constructor ‘Jzon::Writer::Writer(const Jzon::Node&, const Jzon::Format&)’:
Jzon.h:380: warning: ‘Jzon::Writer::root’ will be initialized after
Jzon.h:378: warning: ‘Jzon::FormatInterpreter* Jzon::Writer::fi’
Jzon.cpp:843: warning: when initialized here
Jzon.h: In constructor ‘Jzon::Writer::Writer(const Jzon::Node&, const std::string&, const Jzon::Format&)’:
Jzon.h:380: warning: ‘Jzon::Writer::root’ will be initialized after
Jzon.h:378: warning: ‘Jzon::FormatInterpreter* Jzon::Writer::fi’
Jzon.cpp:847: warning: when initialized here
Jzon.cpp: In member function ‘bool Jzon::Parser::assemble()’:
Jzon.cpp:1060: warning: enumeration value ‘T_SEPARATOR_NODE’ not handled in switch
Jzon.cpp:1060: warning: enumeration value ‘T_SEPARATOR_NAME’ not handled in switch

How to get Array?

I'm having a JSON like below
{ "String1":"Hello", "Array1":[ [0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9] ], "Array2":[ [0.7, 0.8, 0.9], [0.1, 0.2, 0.3], [0.4, 0.5, 0.6] ] }
How do I get Array1 & Array2 out of this JSON and store it?

Reading nested json structure

Hi, I would like to read a nested json structure like this one:

{
 "Observer" : [ 
 "x" : 8.3, 
 "y" : 0.0 ],
 "Grid" : [
 "a" : 0,
 "b" : "test" ]
}

The following code can read the values (e.g., 8.3, 0) but not the names associated (x, y):

const Jzon::Array &stuff = rootNode.Get("Observer").AsArray();
for (Jzon::Array::const_iterator it = stuff.begin(); it != stuff.end(); ++it)
{
   std::cout << (*it).ToString() << std::endl;
}

Can you suggest me an alternative way of doing it?

Add error handling

Add a way to handle errors from the parser when trying to parse an invalid file.

compilation error in VC++ 2008 express

just made simple main file got lots of compilations errors:

include "Jzon.h"

int main(int argc,char** argv[])
{

Jzon::Object rootNode;
if(Jzon::FileReader::ReadFile("d:\\dev\\SVN_client\\trunk\\google.code.projects\\FB_GraphApi_v2\\ping_group_result31.12.2012.json", rootNode))
{

}
else
{
    cout << "Unable to open file"; 
}




return 0;

}

error:

1>------ Build started: Project: FBJsonFormater2, Configuration: Debug Win32 ------
1>Compiling...
1>Jzon.cpp
1>c:\program files\microsoft visual studio 9.0\vc\include\utility(48) : warning C4181: qualifier applied to reference type; ignored
1> d:\dev\svn_client\trunk\google.code.projects\fbjsonformater\fbjsonformater2\fbjsonformater2\jzon.h(207) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\utility(48) : warning C4181: qualifier applied to reference type; ignored
1>c:\program files\microsoft visual studio 9.0\vc\include\utility(48) : error C2529: '_Val2' : reference to reference is illegal
1>d:\dev\svn_client\trunk\google.code.projects\fbjsonformater\fbjsonformater2\fbjsonformater2\jzon.h(207) : error C2665: 'std::pair<_Ty1,_Ty2>::pair' : none of the 3 overloads could convert all the argument types
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(48): could be 'std::pair<_Ty1,_Ty2>::pair(const _Ty1 &,_Ty2 (&))'
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> while trying to match the argument list '(std::string, Jzon::Node)'
1>d:\dev\svn_client\trunk\google.code.projects\fbjsonformater\fbjsonformater2\fbjsonformater2\jzon.h(224) : error C2665: 'std::pair<_Ty1,_Ty2>::pair' : none of the 3 overloads could convert all the argument types
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(48): could be 'std::pair<_Ty1,_Ty2>::pair(const _Ty1 &,_Ty2 (&))'
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> while trying to match the argument list '(const std::string, Jzon::Node)'
1>FBJsonFormater2.cpp
1>c:\program files\microsoft visual studio 9.0\vc\include\utility(48) : warning C4181: qualifier applied to reference type; ignored
1> d:\dev\svn_client\trunk\google.code.projects\fbjsonformater\fbjsonformater2\fbjsonformater2\jzon.h(207) : see reference to class template instantiation 'std::pair<_Ty1,_Ty2>' being compiled
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1>c:\program files\microsoft visual studio 9.0\vc\include\utility(48) : warning C4181: qualifier applied to reference type; ignored
1>c:\program files\microsoft visual studio 9.0\vc\include\utility(48) : error C2529: '_Val2' : reference to reference is illegal
1>d:\dev\svn_client\trunk\google.code.projects\fbjsonformater\fbjsonformater2\fbjsonformater2\jzon.h(207) : error C2665: 'std::pair<_Ty1,_Ty2>::pair' : none of the 3 overloads could convert all the argument types
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(48): could be 'std::pair<_Ty1,_Ty2>::pair(const _Ty1 &,_Ty2 (&))'
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> while trying to match the argument list '(std::string, Jzon::Node)'
1>d:\dev\svn_client\trunk\google.code.projects\fbjsonformater\fbjsonformater2\fbjsonformater2\jzon.h(224) : error C2665: 'std::pair<_Ty1,_Ty2>::pair' : none of the 3 overloads could convert all the argument types
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\utility(48): could be 'std::pair<_Ty1,_Ty2>::pair(const _Ty1 &,_Ty2 (&))'
1> with
1> [
1> _Ty1=std::string,
1> _Ty2=Jzon::Node &
1> ]
1> while trying to match the argument list '(const std::string, Jzon::Node)'
1>d:\dev\svn_client\trunk\google.code.projects\fbjsonformater\fbjsonformater2\fbjsonformater2\fbjsonformater2.cpp(16) : error C2065: 'cout' : undeclared identifier
1>Generating Code...

error of conversion

the code

Jzon::Node array = Jzon::array();
....
Jzon::Node::const_iterator it = array.begin();

gave me the error

conversion from `Jzon::Node::iterator` to non-scalar type `Jzon::Node::const_iterator` requested

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.