How is Firefox converting output of a websocket to JSON? - websocket

I've got the following output in my console on Firefox and I wonder how Firefox is converting the message from a socket to JSON.
The return message look like the following raw:
a["MESSAGE\ntype:READY\ndestination:/user/request-response\ncontent-type:text/plain;charset=UTF-8\nsubscription:/user/request-response\nmessage-id:hantadlb-275772248\ncontent-length:0\n\n\u0000"]
and
a["MESSAGE\nid:/api/items/list/soccer-classes-with-match-events\ndestination:/user/request-response\ntype:FULL\ncontent-type:application/json\nsubscription:/user/request-response\nmessage-id:hantadlb-275772259\ncontent-length:1727\n\n{\"id\":\"soccer-classes-with-match-events\",\"valid\":true,\"lastTouched\":\"2022-03-05T08:53:37.997+00:00\",\"versionTag\":12,\"lastModified\":\"2022-03-05T08:51:37.674+00:00\",\"itemIds\":[{\"id\":\"soccer-gr\"},{\"id\":\"soccer-uk\"},{\"id\":\"soccer-es\"},{\"id\":\"soccer-it\"},{\"id\":\"soccer-de\"},{\"id\":\"soccer-fr\"},{\"id\":\"soccer-pt\"},{\"id\":\"soccer-nl\"},{\"id\":\"soccer-int31\"},{\"id\":\"soccer-be\"},{\"id\":\"soccer-tr\"},{\"id\":\"soccer-br\"},{\"id\":\"soccer-int33\"},{\"id\":\"soccer-ar\"},{\"id\":\"soccer-mx\"},{\"id\":\"soccer-at\"},{\"id\":\"soccer-za\"},{\"id\":\"soccer-sco\"},{\"id\":\"soccer-ch\"},{\"id\":\"soccer-int40\"},{\"id\":\"soccer-se\"},{\"id\":\"soccer-ro\"},{\"id\":\"soccer-au\"},{\"id\":\"soccer-jp\"},{\"id\":\"soccer-lt\"},{\"id\":\"soccer-dz\"},{\"id\":\"soccer-ao\"},{\"id\":\"soccer-am\"},{\"id\":\"soccer-az\"},{\"id\":\"soccer-bh\"},{\"id\":\"soccer-bo\"},{\"id\":\"soccer-bg\"},{\"id\":\"soccer-cl\"},{\"id\":\"soccer-co\"},{\"id\":\"soccer-cr\"},{\"id\":\"soccer-hr\"},{\"id\":\"soccer-cy\"},{\"id\":\"soccer-cz\"},{\"id\":\"soccer-dk\"},{\"id\":\"soccer-ec\"},{\"id\":\"soccer-sv\"},{\"id\":\"soccer-ee\"},{\"id\":\"soccer-fo\"},{\"id\":\"soccer-fi\"},{\"id\":\"soccer-ge\"},{\"id\":\"soccer-gh\"},{\"id\":\"soccer-hn\"},{\"id\":\"soccer-hu\"},{\"id\":\"soccer-is\"},{\"id\":\"soccer-in\"},{\"id\":\"soccer-id\"},{\"id\":\"soccer-ir\"},{\"id\":\"soccer-ie\"},{\"id\":\"soccer-il\"},{\"id\":\"soccer-ivory-coast\"},{\"id\":\"soccer-kz\"},{\"id\":\"soccer-kw\"},{\"id\":\"soccer-my\"},{\"id\":\"soccer-ma\"},{\"id\":\"soccer-ni\"},{\"id\":\"soccer-pa\"},{\"id\":\"soccer-py\"},{\"id\":\"soccer-pe\"},{\"id\":\"soccer-pl\"},{\"id\":\"soccer-kr\"},{\"id\":\"soccer-sa\"},{\"id\":\"soccer-sn\"},{\"id\":\"soccer-simulated-reality-league-(virtual)\"},{\"id\":\"soccer-sg\"},{\"id\":\"soccer-sk\"},{\"id\":\"soccer-si\"},{\"id\":\"soccer-th\"},{\"id\":\"soccer-tn\"},{\"id\":\"soccer-us\"},{\"id\":\"soccer-ae\"},{\"id\":\"soccer-uy\"},{\"id\":\"soccer-ve\"},{\"id\":\"soccer-vn\"},{\"id\":\"soccer-wf\"}]}\u0000"]
Is there any easy way to convert this to JSON without cleaning and formatting the data with a custom function?
I know in general a code example of what I tried is needed but I'm simply asking if there's a built-in function or a library that can do this for me instead of writing the code myself.

Related

Generating Dynamic SSML from "HTTP Request" to be used on a "Get Input"

I'm wondering if anyone can be of assistance.
I am trying to generate some dynamic Amazon Polly SSML to be used on the Plivo PHLO platform. When someone dials into a particular number, they should be greeted with a custom message (in a particular language) and prompted to enter a number.
I have an HTTP request that hits my API, which receives the request and generates the SSML using Plivo's PHP Server SDK.
$response = new Response();
$speak_elem = $response->addSpeak($result['text'], ['language'=> 'en-US, 'voice'=>"Polly.Joanna"]);
Header('Content-type: text/xml');
die( $response->toXML() );
It seems to me that this HTTP Request is working perfectly and returning perfect SSML. When I copy and hard-code-paste the SSML into the Get Input node, it works OK.
<?xml version="1.0" encoding="utf-8"?>
<Response><Speak language="en-US" voice="Polly.Joanna">Welcome To 101 Broadway. For English, press 1.</Speak></Response>
However, when I try to add a Get Input component and link it's "prompt" audio to the resulting SSML, I am getting an error that says Invalid SSML (See Screenshots at the bottom).
WHAT I'VE TRIED
I've tried returning the SSML in plain XML and using {{HTTP_Welcome.response}}
I've tried returning the SSML as text in a JSON object called SSML and using {{HTTP_Welcome.response.SSML}}
I've tried returning the SSML both with and without the xml tag.
I've tried returning the SSML both with and without the Result tag.
I've tried taking a break and coming back to it. Hey, you never know.
No matter how I return the SSML, and how I try to link it to the Get Input prompt, I am unsuccessful. I'm starting to wonder if this is even possible?
Any help would be immensely appreciated. Thanks!
SCREENSHOT 1
SCREENSHOT 2
My name is Mohammed Huzaif, and I work for Plivo as a Developer Evangelist.
Unfortunately, the "GetInput node" in PHLO does not yet implement the feature you are searching for. The best option is to use a standard speak which is customisable in your way, which may have a less natural feel than SSML.
Currently, I've narrow information about your use case as of now but If you still want to use a custom SSML, I'd recommend utilising a framework instead of PHLO to design your call flow. Here's a tutorial that covers a few use cases by Plivo in several frameworks to help you develop one.
If you experience any problems, please feel free to contact our support team.

Structure of amadeus api https

usualy when I use API's I paste the entire url in browser and it print it out json format using json pro extension in chrome. Like this is a lot easier to copy the path of some data and render it to the page.But my problem is I don't know structure of https. I am not sure where I have to insert the key and secret code. In command line I print all data but I cannot get the path of specific data without using json probextension. Help please. Thank you
I recommend to read the following article:
https://developers.amadeus.com/self-service/apis-docs/guides/authorization-262
and later, review the following repository, you could tinker with the curl request here:
https://github.com/amadeus4dev/amadeus-code-examples
https://github.com/amadeus4dev/amadeus-code-examples/blob/master/airline_code_lookup/v1/get/curl/airline_code_lookup.sh

Paw: Possible to copy/paste data from Hash/Dictionary source in target language?

I'm using Paw to integrate with an API and it's a great tool, but the codebase I'm working in has lots of data in Ruby Hashes already that I would like to bring into Paw for testing. Moreover, I would like to be able to copy the data out of a Paw response for use in Ruby code rather than having to copy JSON and either store it as a String and parse it in my code or manually convert it to a native dictionary data structure. Is this possible?

Up to date, working Google apps-script example integrated with spreadsheet?

I'm trying to build some kind of GUI on top of/embedded into a google spreadsheet.
I've been crawling through the docs, and sadly, hitting a wall.
I DID find the sample video, at
http://www.youtube.com/watch?v=5VmEPo6Rkq4
Unfortunately, it seems out of date and broken :( Some of the calls are no longer valid.
And, while I think I figured that part out, I cant get the callback handler to be recognized.
It gives me a runtime error of
"Error encountered: Script function not found:
function respondToSubmit(e) {
/* full body of function here*/
}"
The odd thing is, for supposedly not finding it, it does a good job of printing out the whole function body.
It doesnt seem to be an error inside the function itself, because when I make it an EMPTY function, it still gives the same error :(
Could someone please point me to a simple, working example of how to add a UI alongside a google spreadsheet, or equivalent?
Please note that I dont need a general-purpose, standalone application(I think).
I'm just trying to embed some GUI type functions, in one very specific google spreadsheet that I have.
There are examples of simple Spreadsheet UIs using three different approaches in the
Dialogs and Sidebars in Google Apps documentation. They all work today. The third approach, Custom Dialogs, can be implemented using UiService or HtmlService, but that page only shows an example using HtmlService.

How to handle server errors using jqgrid.net mvc in add or edit dialog

I am trialing jqgrid.net mvc and have noticed that any server error that happens in an add or edit popup dialog, ends up rendering the entire error page in the popup, which is not very pretty. Does anyone know if it is possible to handle this better and perhaps just put a brief message in the dialog instead, a bit like the way validation errors are handled.
You can use errorTextFormat. You can find some code fragments in the answer and in the answer. I would recommend you to post HTTP error messages in JSON format. For example, in case of ASP.NET MVC you can use HandleJsonExceptionAttribute described here. It will convert all unhandled exceptions in the severe code to JSON response instead of default HTML response. You can easy modify the code to provide JSON response only if the client requested JSON format in the server response. The JSON response you can easy parse, but even in case of pure HTML response you get only the most important part of the response with respect of jQuery selectors and return from your implementation of the errorTextFormat callback.

Resources