コード例 #1
0
bool JSONArray::serialize(JSONWriter &writer){
	if (_elements.size() > 0){
		writer.writeStartArray();
		bool wroteOne = false;
		for (auto iter = _elements.begin(); iter != _elements.end(); iter++){
			if (*iter && (*iter)->hasValue()){
				if (wroteOne){
					writer.writeRaw(",");
				}
				writer.writeNext();
				(*iter)->serialize(writer);
				wroteOne = true;
			}
		}
		writer.writeEndArray();
		return true;
	}
	return false; 
}
コード例 #2
0
bool JSONObject::serialize(JSONWriter &writer){
	if (_properties.size() > 0){
		writer.writeStartObject();
		bool wroteOne = false;
		for (auto iter = _properties.begin(); iter != _properties.end(); iter++){
			if (iter->second && (*(iter->second)).hasValue()){
				if (wroteOne){
					writer.writeRaw(",");
				}
				writer.writeNext();
				writer.writeKey(iter->first);
				writer.writeRaw(": ");
				(*(iter->second)).serialize(writer);
				wroteOne = true;
			}
		}
		writer.writeEndObject();
		return true;
	}
	return false;
}