This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(zoo) | |
library(V8) | |
lexicon <- | |
'\\lx rouge | |
\\ps adjective | |
\\de red | |
\\xv La chaise est rouge | |
\\xe The chair is red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Postman is an exceptionally useful tool for testing ReST apis. | |
The following is an example of how to use the xml2Json method in a test if you are getting back xml and want to test elements in the response. The reason that I am posting this is that I could not get xml2Json to work until I discovered (using the new console in Version 4.7.2) that I needed the include the .$. in the object reference. | |
So that this is completely self contained all this is doing is setting an env var with an xml string, getting that | |
var, converting it to json and then evaluating the content. | |
postman.setEnvironmentVariable("testresponse", "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><myResponse isError=\"false\"/>"); | |
var xmlresponse = postman.getEnvironmentVariable("testresponse"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//return an array of objects according to key, value, or key and value matching | |
function getObjects(obj, key, val) { | |
var objects = []; | |
for (var i in obj) { | |
if (!obj.hasOwnProperty(i)) continue; | |
if (typeof obj[i] == 'object') { | |
objects = objects.concat(getObjects(obj[i], key, val)); | |
} else | |
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not) | |
if (i == key && obj[i] == val || i == key && val == '') { // |