Click here to Skip to main content
15,889,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am converting a desktop app to a client version of a client/server app.

I need JSON data to be used in a function call like

void ProcessData(long long Type,long long Kind, long long Shape,long long Index,Json::Value &jValue )
{
   int iState = 1;
   jValue[Type][MakeString(Kind)][Shape][MakeString(Index)] = 1;
}


Where MakeString() is a function that converts from long long to string.

The problem is that the operator[] reports that there are numerous matches for the argument type.

How can I get round the numerous argument type considering the fact that the code that json is being introduced to already has a structure.

If there is a better way to handle this, I'll like to know.Its just that the parameter of the function are fixed.

What I have tried:

I have spent several hours googling for a solution.
Posted
Updated 21-Oct-17 22:54pm
Comments
Richard MacCutchan 22-Oct-17 3:07am    
What is the definition of MakeString, what is the definition of jValue? Please make more effort to provide proper details in your questions.
Gbenbam 23-Oct-17 3:53am    
Json::Value is a JsonCpp Value type it will be familiar to people ho use JsonCpp.

std::string MakeString(long long llValue)
{ char Buffer[100];
sprintf(buffer,"%lld",llValue);

return std::string(Buffer);
}

1 solution

If the type conversion isnt clear, you run into trouble of getting strange bugs. It better to enforce the explicit type conversion like this:
C++
[(const char*) MakeString(Index)] 

It could be that the automatic cast from the string is the original problem. I dont like such concatenated expressions, because it make debugging harder.
C++
String s= MakeString(Index);
[(const cahr*) s] // use result in json 
 
Share this answer
 
Comments
Gbenbam 22-Oct-17 9:59am    
Its the numeric indexing that is the problem not the string.

It says there three possible matches: namely, int, long , long long.

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