Sending JSON objects from Native Messaging

Confirmed Issue #13285321 • Assigned to Rahul R.

Details

Author
Greg D.
Created
Aug 16, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
40.15063
Reports
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

How do you send an object with multiple values, rather than just a string?

Unfortunately the C#/C++ examples only show sending a single string value, as message or response.

I’ve managed sending a value from native messaging UWP AppService

            ValueSet valueSet = new ValueSet();
            valueSet.Add("Anything here?", "Text here");
            await connection.SendMessageAsync(valueSet);

In Edge extension background script gets String value "Text here", makes sense as a string was sent.

In Chrome/Firefox because of text based stream, you serialize the object, so tried the same for Edge

            Dictionary<string, object> result = new Dictionary<string, object>
                    {
                        { "Command", "BRIDGE NOT AVAILABLE" },
                        { "NoResult", true }
                    };

            ValueSet valueSet = new ValueSet();
            valueSet.Add("message", JsonConvert.SerializeObject(result, Formatting.Indented));
            await connection.SendMessageAsync(valueSet);

But here the string wasn’t parsed back into an object, but left as a string.

recieved message from native app: message:  {
  "Command": "BRIDGE NOT AVAILABLE",
  "NoResult": true
}
background.js 

In Chrome/Firefox this is an object parsed from the stream.

I also tried sending a ValueSet hoping for object, but it didn’t even show up in the console log, not sure where it went.

            ValueSet valueSet = new ValueSet();
            valueSet.Add("Command", "getUrl");
            ValueSet msg = new ValueSet();
            msg.Add("Message", valueSet);
            await connection.SendMessageAsync(valueSet);

Attachments

0 attachments

    Comments and activity

    • Microsoft Edge Team

      Changed Title from “Sending JSON objects from Native Messaging” to “Sending JSON objects from Native Messaging”

      Changed Assigned To to “Rahul R.”

    • It seems that this issue is same as the one I reported in the following ticket.
      https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13055670/

    • Thanks @Anon yes it does seem to be the same issue.

    • Microsoft Edge Team

      Changed Status to “Confirmed”

      Changed Status from “Confirmed”

      Changed Status to “Confirmed”

    You need to sign in to your Microsoft account to add a comment.

    Sign in