Search query for JSON data by url - json

I'm using the following url for my JSON data.
myapp/laravelRoute/jsondata
when entering this in address bar, following JSON array will be displayed
[{"A":"B"},{"B":1},{"C","http"}]
But, when I enter the url as,
myapp/laravelRoute/jsondata?search=B
it shows the entire array instead showing the search result. How I do this correctly?

After doing the code view I found that the array route is configured for a default route in Laravel Routes. So, in any case that open a path except mentioned ones in routes will redirect to the default path.

Related

Passing Route Parameters with ngfor

I have to create an Angular website. The first page has static content and I made the second page with an ngfor because I got a JSON file with a tree structure of a productrange and with that I wrote a method which get me the node I selected on the static website. On the static website I gave hard coded key params, which I used in the next component to get my node because the JSON file had a key as well and I had to get the selected node with this key. But the second page content get loaded with and ngfor, which loads a list, that I get from the treemodel so I don't have a fix key, and I don't know how to get the key I want. I will send some screenshots with this question so you maybe get what I want to ask.Code of the first static page with the hardcoded keys:
My both router paths in the app routes ts:
How i get my key param as a string:
My loops to get the data from the tree into arrays:
The ng for with the key param which i dont know how to get out when i click on one of the elements in the last screenshot:
This is the page, which got loaded with the ng for:

Get image URL from google places web API (nearby search)

when I run the following HTTP request:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?key=[API KEY]&location=${lat},${lng}&radius=400
..i get a response which is an array of objects (places)...each object has a key called photos (which is also an array of objects). I dont see a "getURL" method, so how do I get the image URL for the place?
Thanks
The Places API web service returns array of photos in the response. Each element in this array has a photo_reference field. So you can use the photo reference to get a photo using the following URL:
https://maps.googleapis.com/maps/api/place/photo?photoreference=YOUR_PHOTO_REFERENCE&maxwidth=600&key=YOUR_API_KEY
For further details have a look at the documentation:
https://developers.google.com/places/web-service/photos
I hope this helps!

How to use responses from a Jmeter JDBC Request in a HTTP Request

Here's my situation:
I want to do this:
I have a list of URLs in a MySQL database which I want to hit using a HTTP Request to see if the response is a HTTP Status code of 404 or not.
I have done this:
Added and configured a JDBC Config Element.
Added and configured a JDBC Request Sampler. Basically a select statement that returns a table with 8 columns. I have provided 8 comma-separated variables for the 'Variable names' field, so that the results of the JDBC request can be identified with these variable names.
Created a HTTP Request Sampler that uses one of those variables ${url} in the 'Server Name or IP' field.
Though the JDBC request works flawlessly and returns a table with a bunch of rows, the problem with this is that the HTTP Request Sampler never picks up the variable from the JDBC Request result.
The HTTP Request looks like this in the 'View Results Tree':
GET http://${url}/
I have tried these solutions:
Add 'Save Responses to a File' listener to the JDBC Request. This creates a file of type '.plain' and not a CSV. Had it been a CSV, I could have utilized that CSV file by creating a CSV Data Set Config. So this attempt failed.
I have tried forcing the file name in the above attempt to always use 'C:\JMETERTest\data.csv'. But it ends up creating a new file named 'C:\JMETERTest\data.csv1.plain'. This attempt failed too.
I tried to reference the URL column as ${url_1} in the HTTP Request's Server Name field. It worked. But the problem now is that in the results tree, all the requests are going for the the URL from only the first row of the result set. I see that this is because of the row number '_1' specified in the ${url_1} above. I can use this if someone can suggest a way to parameterize the '_1' into a variable that I can loop through (probably using a 'Counter' element). I created a Counter Config Element by the Reference Name 'loopCounter'. And used this in the Server Name field of the HTTP Request:
${url_("${loopCounter}")}
But now my HTTP Requests look lamer:
GET http://${url_("${loopCounter}")}/
This did not work too.
Solution 3 looks more doable to be only if I could resolve the parameterization of the row number.
I am open to JMeter Plugin suggestions too.
I will update anything else that I try as we go on.
P.S. Please let me know if my question is not clear in anyway.
Have you tried wrapping the HTTP sampler in a ForEach controller (parent) where the variable for the controller is the URL variable obtained from the JDBC sampler?
Also, the output variable in the ForEach will be the variable you now use in the HTTP sampler.
That way it will iterate through each variable from the beginning of the index to the end and run the sampler once each time.
In 'Save responses to a File' Listener, Select Checkboxes "Don't add Suffix and Prefix". Checking these two options will ensure, you get exact Log file name.

trouble understanding json and jquery-ui autocomplete

I'm trying to use the jquery-ui autocomplete and I'm having trouble fully understanding how to hook it up.
In an effort to see functionality, we exported a list of user names in the json format of
["Abbott, Bob",
"Adams, Jo", etc...
and it's over 8k lines. I saved this into a file called names.json. When I set up my autocomplete, I used the following:
$("#userName").autocomplete({
source: "names.json"
});
Based on the jqueryi-ui autocomplete page. It says this:
When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data.
It returns all 8k+ names instead of filtering it based on what I'm typing. I tried changing it to:
$("#userName").autocomplete({
source: "names.json?term="
});
That didn't work to filter it either.
I've tried variations on the remote JSONP datasource example, but I can't seem to get it to work.
I've tried changing my json file to the format of:
[{"value":"Abbot, Bob"},
{"value":"Adams, Jo"}, etc...
That didn't filter.
I've tried taking out the quotes around value. That didn't return anything.
I've tried changing it to the format listed in the answer for this stackoverflow question returning item.value with my second json format but that didn't filter it either.
I'm not quite sure what I'm doing wrong and I hope to understand. Thank you.
Your datasource needs to by dynamic.
jquery ui autocomplete is going to send a request to the URL you have specified with ?term=WHATEVER_THE_USER_TYPED appended. You need something on the server side that will process that request and return just the data for that term.
For instance,
$("#userName").autocomplete({
source: "names.php" // php as an example.
});
Will result in a request to:
/names.php?term=abcd
names.php would have to pull back the data that matches the search and return it.

Google JSON/Ajax API - how do you get the next page of results?

According to : http://code.google.com/apis/ajaxsearch/documentation/#fonje
I get back a cursor result, but stupidly, the moreResultsUrl returns a URL NOT to the JSON service but to the main site - how do instead fetch the next page of results into JSON?
Well, that's because moreResultsUrl is pointing to http://www.google.com/search instead of http://ajax.googleapis.com/ajax/services/search/web.
What you need are just the parameters of the moreResultUrl which you can pass to http://ajax.googleapis.com/ajax/services/search/web for the JSON result.
For example:
http://www.google.com/search?v=1.0&q=Luca
is translated in JSON with
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Luca
Google is just showing you their RESTful api, it's up to you to use the pages JSON value with whatever interface you want.