zguy / jzon Goto Github PK
View Code? Open in Web Editor NEWC++ JSON Parser
Home Page: http://zguy.github.io/Jzon
License: MIT License
C++ JSON Parser
Home Page: http://zguy.github.io/Jzon
License: MIT License
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
Please fix it, a lot of stuff are missing now. Getting a lot of errors.
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?
Some characters should be escaped before being written, for example the " character.
Add missing getter for unsigned long long and long long, in "ToXXX" family of methods.
Currently there are none, i had to manually add them
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 a way to handle errors from the parser when trying to parse an invalid file.
just made simple main file got lots of compilations errors:
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...
Jzon currently only supports plain ASCII data.
Add support for more encodings (UTF-8, etc..).
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
https://github.com/vivkin/jzon
I assume this is just an accident?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.