Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello. I am working on parsing json in c++.
json format is
{
{
"product":"12456",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"12456"
}
}


I can't find json parser library can parse that format json.

Help me.

Thanks in advance.

What I have tried:

I tried with jsoncpp-master, rapidson-master, restful-mapper-master
cpprestsdk-master.
Posted
Updated 18-Apr-16 21:56pm
v2
Comments
CPallini 19-Apr-16 3:50am    
OK, you tried various libraries. Why are they failing?
Member 12179079 19-Apr-16 4:00am    
in my mind they can parse {"product:", "123", "product", "1234"}
but can't parse {
{
"product":"12456",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"12456"
}
}

if you know the source code of doing that.
teach me.
Thanks.
CPallini 19-Apr-16 4:54am    
Why not? That is just an array.
enhzflep 19-Apr-16 10:04am    
It would be if the enclosing braces were [ and ]

I think the decoder is not the problem, but rather, it's a matter of invalid output produced by the encoder.

Your json should begin and end in [ ] not { } : JSONLint - The JSON Validator.[^]
JavaScript
[
{
"product":"12456",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"12456"
}
]
 
Share this answer
 
Quote:
{
{
"product":"12456",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"5698"
}
,
{
"product":"124565",
"variant":"12456"
}
}

May be all libraries agree that your data is not JSON format.
 
Share this answer
 
v4
Comments
[no name] 19-Apr-16 4:13am    
Does also not Looks like a valid json Format :)

Online JSON Viewer[^]

N.B.1: Mehdi Gholam's one is right.
N.B.2: No vote from my side
Patrice T 19-Apr-16 4:24am    
Didn't try to correct it.
Just a Quote from question.

Perfectly fine with N.B.2 :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900