var nativeData = {
clientName: msg.clientName,
requestId: msg.requestId,
- data: bundle.toString()
+ data: bundle
};
var result = native_.callSync('MediaControllerServer_replyCommand', nativeData);
var nativeData = {
command: args.command,
- data: bundle.toString(),
+ data: bundle,
name: this.name,
listenerId: ReplyCommandListener.listenerName
};
CHECK_EXIST(args, "requestId", out)
CHECK_EXIST(args, "data", out)
- auto serialized_data = args.get("data").get<std::string>();
- picojson::value json;
- std::string err = picojson::parse(json, serialized_data);
- if (!err.empty()) {
- LoggerE("json parse error: %s", err.c_str());
- return;
- }
-
+ picojson::value json = args.get("data");
auto result = server_->CommandReply(args.get("clientName").get<std::string>(),
args.get("requestId").get<std::string>(), json);
free(request_id);
};
- auto serialized_data = args.get("data").get<std::string>();
- picojson::value json;
- std::string err = picojson::parse(json, serialized_data);
- if (!err.empty()) {
- LoggerE("json parse error: %s", err.c_str());
- return;
- }
-
- PlatformResult result =
- client_->SendCommand(args.get("name").get<std::string>(),
- args.get("command").get<std::string>(), json, reply_cb, &request_id);
+ PlatformResult result = client_->SendCommand(
+ args.get("name").get<std::string>(), args.get("command").get<std::string>(),
+ args.get("data"), reply_cb, &request_id);
if (result) {
ReportSuccess(out);
};
if (!data.is<picojson::null>()) {
- ScopeLogger("data is not null");
bundle = bundle_create();
const picojson::object& json = data.get<picojson::object>();
PlatformResult result = common::JsonToBundle(json, bundle);
var result = (new tizen.Bundle(json)).toJSON();
assertEqual(json.key1, result.key1, 'key1 differs');
assertArrayEqual(json.key2, result.key2, 'key2 differs');
- assertEqual(true, result.key3 instanceof Uint8Array, 'key3 not Uint8Array');
+ assertEqual(true, Array.isArray(result.key3), 'key3 not an array');
assertEqual(result.key4.length, json.key4.length, 'key4 length differs');
- assertEqual(true, result.key4[0] instanceof Uint8Array, 'key4[0] element not Uint8Array');
- assertEqual(true, result.key4[1] instanceof Uint8Array, 'key4[1] element not Uint8Array');
+ assertEqual(true, Array.isArray(result.key4[0]), 'key4[0] element not an array');
+ assertEqual(true, Array.isArray(result.key4[1]), 'key4[1] element not an array');
assertArrayEqual(json.key4[0], result.key4[0], 'key4[0] differs');
assertArrayEqual(json.key4[1], result.key4[1], 'key4[1] differs');
}
exports.Bundle.prototype.toJSON = function() {
var json = {};
- this.forEach(function(key, value) {
- json[key] = value;
- });
- return json;
-};
-
-// Conversion from Uint8Array to Array happens in toString instead of toJSON
-// because toJSON method should preserve bundle values types.
-exports.Bundle.prototype.toString = function() {
- var json = {};
this.forEach(function(key, value, type) {
if (type == BundleValueType.BYTES) {
json[key] = [].slice.call(value);
json[key] = value;
}
});
- return JSON.stringify(json);
+ return json;
+};
+
+exports.Bundle.prototype.toString = function() {
+ return JSON.stringify(this);
};