Project

General

Profile

Problem with Json::Array

Added by Fahmi Noorain about 10 years ago

Hi,

I get this error whenever I try to push_back into Json::Array.

invalid use of incomplete type 'struct Wt::Json::Array'
forward declaration of 'struct Wt::Json::Array'

And this is my source code.

@// First Item

Json::Value item0(Json::ObjectType);

Json::Object &rItem0 = item0;

rItem0["title"] = Json::Value(WString("Colgate Kodomo"));

rItem0["distance"] = Json::Value(WString("12KM"));

rItem0["price"] = Json::Value(WString("MYR12.99"));

// Second item

Json::Value item1(Json::ObjectType);

Json::Object &rItem1 = item1;

rItem1["title"] = Json::Value(WString("Kambing Hitam"));

rItem1["distance"] = Json::Value(WString("13KM"));

rItem1["price"] = Json::Value(WString("MYR0.50"));

// List of items

Json::Value items(Json::ArrayType);

Json::Array &rItems = items;

rItems.push_back(item0);

rItems.push_back(item1);

JSONObject["status"] = Json::Value(error);

JSONObject["items"] = Json::Value(items);@

Thank you Wt team for great framework / product especially for C developer like us!


Replies (2)

RE: Problem with Json::Array - Added by Marco M about 10 years ago

Hi,

invalid use of incomplete type 'struct Wt::Json::Array'

forward declaration of 'struct Wt::Json::Array'

this is basic C, nothing to do with Wt:

#include <Wt/Json/Array>

RE: Problem with Json::Array - Added by Fahmi Noorain about 10 years ago

Thanks Marco...I feel soooo stupid right now, I forgot to check the 'include' part after merge my code from repo. :-)

    (1-2/2)