I have a json data which looks like this:
{
"id": 355,
"title": "ZISIMOPOULOS LTD",
"cat": "Contractor - High Pressure, Cutting & Breaking, Hydrodemolition, Surface Preparation - UHP, Tube, Pipe & Bundle Cleaning",
"catids": {
"1": 17,
"2": 18,
"3": 21,
"4": 26,
"5": 27
},
"link": "http://wja.dev/members/zisimopoulos-ltd/",
"memberType": "C1 - Water Jetting Contractor",
"email": "info#zisimopoulos.gr",
"telephone": "302104412004",
"fax": "302104416524",
"website": "www.zisimopoulos.gr",
"instructor": false
}
Each member has catids associated to it.
Now i need the filteration function, where on clicking on the categories in the left will list the member associated to that categories.
Filteration page layout
Thanks in advance.
Related
I have the following HTTP Post with the following payload
{
"externalCode": "999",
"name": "PNNL - Winthrop, WA (Sundown L",
"description": "Winthrop",
"geozoneFlx": "PNL",
"status": "A",
"address1": "135 Sundown Lane",
"city": "WINTHROP",
"state": "WA",
"county": "OKANOGAN",
"country": "USA",
"zipCode": "98862-0339",
"timezone": "PST",
"startDate": "2016-01-27T00:00:00",
"endDate": "9999-12-31T00:00:00"
},
HOWEVER, some data message come into the Logic App looking like this with no "State" "name" in the data like this
"externalCode": "999",
"name": "PNNL - Winthrop, WA (Sundown L",
"description": "Winthrop",
"geozoneFlx": "PNL",
"status": "A",
"address1": "135 Sundown Lane",
"city": "WINTHROP",
"county": "OKANOGAN",
"country": "USA",
"zipCode": "98862-0339",
"timezone": "PST",
"startDate": "2016-01-27T00:00:00",
"endDate": "9999-12-31T00:00:00"
},
I have to say if the data message comes in without the State json Name like above, kick it out. How do I filter for a missing json field such as "State" in the above??
Thanks
Mike
I think you can judge whether the length of the value of the state field is greater than 0, if it is greater than 0, execute your original logic, if the length of the value is 0, you don't need to do anything. The design of the logic app is as follows:
If the request body of your http request is a json array, you can use the for each loop to process.
The expression for obtaining the length of the state field in condition is as follows:
length(coalesce(body('Parse_JSON')?['state'], ''))
For the usage of coalesce and length, you can refer to the official documentation
Can we change the sequence of json items?
For example:
[
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In a complete graph G, which has 12 vertices, how many edges are there?",
"correct_answer": "66",
"incorrect_answers1": "67",
"incorrect_answers2 : "34",
"incorrect_answers3 : "11"
},
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In base 2, what is 1 + 1?",
"incorrect_answers1": "2",
"incorrect_answers2 : "01",
"correct_answer": "10",
"incorrect_answers3 : "11"
},
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In the hexadecimal system, what number comes after 9?",
"incorrect_answers1": "10",
"incorrect_answers2 : "The Number 0",
"correct_answer": "The Letter A",
"incorrect_answers3 : "16"
}
]
As mentioned in the comments that re-ordering JSON data is impossible and also not required.
For the current situation, you have to loop across the parent array containing the JSON objects, create a local array variable to get the list of re-ordered answers, push all the answers to this array and shuffle it using a library like lodash (https://lodash.com/docs/#shuffle) or a custom random functions, whatever works for your needs.
You can place this array within each object of this JSON while looping and give it a meaningful key like shuffled_answers.
So now your item structure will look like this:
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In base 2, what is 1 + 1?",
"incorrect_answers1": "2",
"incorrect_answers2" : "01",
"correct_answer": "10",
"incorrect_answers3" : "11",
"shuffled_answers": ["2", "11", "10", "11"]
}
You can then use this array to display answer choices in your UI to ask user the question and use the correct_answer key to compare the correct answer from the user's choice.
I'm linking here a video tutorial for a very similar App developed in Vue using the above logic. You can refer for more insight about apps like these and use it for your requirements.
Hope that helps.
I am trying to import some data into firebase
{
"people":
[
{
"name": "John Smith",
"age": 23,
},
{
"name": "Tony Jones",
"age": 61,
},
]
}
This is fine but it adds a "traditional" array index in firebase (0,1) - which I believe is bad?
When I insert a new value via my web form I get a mix
"0" : {
"name": "John Smith",
"age": 23,
},
"1" : {
"name": "Tony Jones",
"age": 61,
},
"-LgWkhX2DdD_ChbWJkXo" : { // inserted via form it has a firebase index
"name": "Simon Green",
"age": 37,
}
How can I get the initial inserted data to use firebase indexes it is just a normal .json file.
{
"people":
[
{
"name": "John Smith",
"age": 23,
},
{
"name": "Tony Jones",
"age": 61,
},
]
}
When you write array type JSON data into Realtime Database, you are going to get array type numeric indexes in the database. If you don't want to write like this, you will have to convert the array yourself - there is no API that's going to do that for you. You'll have to read the JSON, iterate each element of the array, and write each item into the database the way you want it to be written. It looks like perhaps you want to add each item using an automatic push ID, since you are trying to create something that looks like "-LgWkhX2DdD_ChbWJkXo".
I am submitting a form for job posting and have skills like C# which escape in my rest API. So I encoded the skills and sending to backend.
"skills":encodeURIComponent(skills)
now when I get back the skills I am doing decodeURIComponent for my skills
$scope.skills = decodeURIComponent(skills);
but this wont work with array of datas, when I want to fetch list of jobs , the datas comes in array , my array has almost 15 key values , which will be used in table some way. Writing a new array and pushing each values into array again pushing decoded skills a big process.
Is any solution to directly decoded the value in view , that is html
I tried {{decodeURIComponent(item.skills) }} but no luck.
sample Data ::
{
"json": {
"response": {
"statusmessage": "Success",
"count": 59,
"data": [
{
"employerId": 2,
"employerEmail": "sumit#infosoftjoin.in",
"employerName": "SumitKumar",
"companyName": "Infosoftjoin%20pvt%20ltd.",
"jobId": 142,
"jobTitle": "Test%20case%201",
"jobDescription": "<p>ahdu%29%28#*%29*W%29%28*%29E%26%3D--%3D</p>",
"link": "http://www.infosoftjoin.in",
"numberOfPositions": 5,
"createdTime": "18-May-2018",
"lastUpdatedTime": "18-May-2018",
"consumedCredits": 44,
"location": {
"city": "North And Middle Andaman",
"state": "Andaman and Nicobar Islands",
"country": "India"
},
"skills": [
"C%23.NET"
],
"approved": 1,
"status": "Approved"
},
{
"employerId": 2,
"employerEmail": "sumit#infosoftjoin.in",
"employerName": "SumitKumar",
"companyName": "Infosoftjoin%20pvt%20ltd.",
"jobId": 130,
"jobTitle": "New%20job",
"jobDescription": "hryuyurfkituo8",
"link": "http://www.infosoftjoin.in",
"numberOfPositions": 5,
"createdTime": "16-May-2018",
"lastUpdatedTime": "16-May-2018",
"consumedCredits": 93,
"location": {
"city": "Nicobar",
"state": "Andaman and Nicobar Islands",
"country": "India"
},
"skills": [
"APACHE TOMCAT"
],
"approved": 1,
"status": "Approved"
}
]
}
}
}
encodeURIComponent is a JavaScript built-in function, you can not access it directly in your AngularJs template. Convert that into a $scope function then try accessing from AngularJs template.
I would suggest you to have a filter for the same instead of $scope function.
Filter:
app.filter('decodeFilter', function() {
return function(input) {
return decodeURIComponent(input);
};
});
Template:
{{item.skills | decodeFilter}}
If still you want that as $scope function then try below code:
Controller:
$scope.decodeComponent=function(value){
return decodeURIComponent(value);
}
Template:
{{decodeComponent(item.skills)}}
Also, please check this plunker for sample scenario with the above examples.
I have Documents they have this structure:
{id: ####,
rev: ####,
"Cam_name": "Camera SX",
"colour": "white",
"manufacturer": "Sony",
"rec_limit": 180,
"Customer": ["Mike","Ann","James"]
}
{id: ####,
rev: ####,
"Cam_name": "PXSV CAM",
"colour": "white",
"manufacturer": "LG",
"rec_limit": 144,
"Customer": ["Mike","Oliver","Mr. Rain"]
}
{id: ####,
rev: ####,
"Cam_name": "LxSV Double",
"colour": "white",
"manufacturer": "Phillips",
"rec_limit": 160,
"Customer": ["Mike"]
}
And i want to make an MAP Function query where i can see ALL Cam_Names which the Customer Mike is using.
i have a simillar Map Function but this shows only the Cam_Name LxSV Double and only the Customer Mike. i want to show all Cam_Names which mike is using.
MyQuery:
function(doc){
if(doc.Customer == "Mike"){
emit(doc.Cam_name, doc.Customer)
This query gives me not the right result.
If your query looks exactly like that, then you have a syntax error. But also, doc.Customer is an array, so you can't do a simple equality check.
But checking the existence of a value in an array is totally unnecessary, your map function can simply look like this:
function (doc) {
doc.Customer.forEach(function (customer) {
emit(customer, doc.Cam_name);
});
}
Then, query your view with /{db}/_design/{ddoc}/_view/{view}?key="Mike"
Your output will look like:
{
"total_rows": 3,
"offset": 0,
"rows": [
{
"id": "####",
"key": "Mike",
"value": "Camera SX"
},
{
"id": "####",
"key": "Mike",
"value": "PXSV CAM"
},
{
"id": "####",
"key": "Mike",
"value": "LxSV Double"
}
]
}
Now, you can use this same view to find any customer, not just whomever you specify in your map function.