32 #include <Ice/ObjectFactory.h>
75 json =
parser.parsedJson->toJsonString(indenting);
82 if (containerInfo->subType)
90 for (JPathNavigator child : nav.select(
"*"))
92 ParseResult r =
CheckUserInput(child.getData(), containerInfo->subType, communicator);
106 for (JPathNavigator child : nav.select(
"*"))
108 ParseResult r =
CheckUserInput(child.getData(), containerInfo->subType, communicator);
153 Ice::ValueFactoryPtr factory = communicator->getValueFactoryManager()->find(containerInfo->typeId);
154 SerializablePtr obj = SerializablePtr::dynamicCast(factory->create(containerInfo->typeId));
155 static Ice::Current
c;
158 jsonObject->fromString(json->toJsonString(0));
161 obj->deserialize(jsonObject,
c);
163 catch (
const UserException& ex)
167 catch (LocalException& ex)
172 VariantDataPtr variant = VariantDataPtr::dynamicCast(obj);
184 return compressed->toJsonString(indenting);
211 return decompressed->toJsonString(0);
219 variant->add(
"typeName", variantBaseTypeName);
252 o->add(
"variant", variant);
253 return o->toJsonString(0);
258 if (containerInfo->subType)
266 throw VariantJsonException(
"Wrong JSON data type. Expected array at ") << nav.getData()->getLexerStartOffset().toLongString();
268 for (JPathNavigator child : nav.select(
"*"))
270 array->add(
Decompress(child.getData(), containerInfo->subType));
273 o->add(
"array", array);
274 o->add(
"type", JsonValue(containerInfo->typeId));
282 throw VariantJsonException(
"Wrong JSON data type. Expected object at ") << nav.getData()->getLexerStartOffset().toLongString();
284 for (JPathNavigator child : nav.select(
"*"))
286 map->add(child.getKey(),
Decompress(child.getData(), containerInfo->subType));
290 o->add(
"type", JsonValue(containerInfo->typeId));
295 throw VariantJsonException(
"Unknown container type: ") << containerInfo->typeId;
301 variant->add(
"typeName", containerInfo->typeId);
302 variant->add(
"value", json->clone());
305 o->add(
"variant", variant);
312 if (containerInfo->subType)
317 for (JPathNavigator child : nav.select(
"array/*"))
319 a->add(
Compress(child.getData(), containerInfo->subType));
326 for (JPathNavigator child : nav.select(
"map/*"))
328 o->add(child.getKey(),
Compress(child.getData(), containerInfo->subType));
334 throw VariantJsonException(
"Unknown container type: ") << containerInfo->typeId;
339 std::string typeName = nav.selectSingleNode(
"variant/typeName").asString();
340 if (typeName != containerInfo->typeId)
342 throw VariantJsonException(
"typeName mismatch. expected: ") << containerInfo->typeId <<
". is: " << typeName;
345 return nav.selectSingleNode(
"variant/value").getData();