i wanted to create a JSON using Aws-sdk for C++. this is what i am doing so far.
void convertStructToAwsJSON()
{
Aws::Utils::Json::JsonValue jsonValue = Aws::Utils::Json::JsonValue();
jsonValue.WithDouble("percentage", 93.6);
jsonValue.WithInteger("age", 25);
float grades[3] = {87, 95, 65};
jsonValue.WithArray("grades", grades);
}
but it seems like it throws an error, saying that it is not of the argument type. I checked the documentation and the only thing I can do is add an array of type String.
const Aws::Utils::Array<Aws::String> grades;
grades[0] = "87";
grades[1] = "95";
grades[2] = "65";
jsonValue.WithArray("grades", grades);
Now it works. How to store it in double or integer instead of string?
Alright got a response from the AWS SDK Team. It can be done like this:
Aws::Utils::Array<Aws::Utils::Json::JsonValue> grades(2);
Aws::Utils::Json::JsonValue value1;
Aws::Utils::Json::JsonValue value2;
grades[0] = value1.AsDouble(3.1416);
grades[1] = value2.AsDouble(164635242.4134452);