I have a json file like below
{
"23": {
"id": 23,
"featured": true,
"name": "Dawid Ostrowski",
"title": "Developer Relations Program Manager",
"company": "Google",
"country": "Switzerland",
"photoUrl": "/images/people/dawid_ostrowski.jpg",
},
"9": {
"id": 9,
"featured": true,
"name": "Mandy Waite",
"title": "Developer Relations Engineer",
"company": "Google",
"country": "UK",
},
"15": {
"id": 15,
"featured": true,
"name": "Jakub Škvára",
"title": "Frontend engineer",
"company": "Shipito",
"country": "Czech Republic",
"photoUrl": "/images/people/jakub_skvara.jpg",
},
"14": {
"id": 14,
"name": "Jana Moudrá",
"title": "Co-Founder",
"company": "Juicymo",
"country": "Czech Republic",
"photoUrl": "/images/people/jana_moudra.jpg"
}
}
I want to get all data of a specific id in Polymer.
like if someone visit example.com/user/23, I want to get the data of 23 so I can display a page using the data.
How do i do it in Polymer?
Assuming you just have one static .json file, and not an API to selectively return JSON strings based on query parameters, you could do the following.
Implement the following method on your Polymer element:
getEntryById: function (id) {
return this.queryResult[id];
}
Use Polymer's iron-ajax element and bind the lastResponse property of this element to queryResult on your new element, and the requestUrl property to the location of your .json file.
Of course, you need some kind of client-side router (like Page.js, included in Polymer Starter Kit) that reads the route and route parameters (the user Id) from the URL and passes it to your Polymer element, so you can appropriately call the getEntryById function.
Related
I have a custom external adapter runnning on a chainlink node. When the adapter is triggered, it gets a response from an api that sends back a json object with a list of objects. I want to covert the array in this json object into a solidity mapping for my smart contract.
For example could I get the property "array of objects" from this response and convert it into a solidity mapping for my client contract to use?
"random": 89,
"random float": 10.669,
"bool": true,
"date": "1980-11-24",
"regEx": "helloooooooooooooooooooooo to you",
"enum": "json",
"firstname": "Stevana",
"lastname": "Killigrew",
"city": "Port Moresby",
"country": "Isle of Man",
"countryCode": "PY",
"email uses current data": "Stevana.Killigrew#gmail.com",
"email from expression": "Stevana.Killigrew#yopmail.com",
"array": [
"Vanessa",
"Chloris",
"Glynnis",
"Fidelia",
"Kaja"
],
"array of objects": [
{
"index": 0,
"index start at 5": 5,
"team": "na",
"company": "CVS",
"department": "hair and beauty"
},
{
"index": 1,
"index start at 5": 6,
"team": "na",
"company": "CVS",
"department": "hair and beauty"
},
{
"index": 2,
"index start at 5": 7,
"team": "na",
"company": "CVS",
"department": "hair and beauty"
}
],
"Ronna": {
"age": 82
}
}```
One can't get an "array of objects" at the moment from the external adapter, here is the list of currently supported response types.
You will need to make a Multi-Varibale Responses request and then get each individual property like this
I am a beginner in angular 4 and using form builder,On ngSubmit I am creating an object containing the data of form fields. However before passing that object as a payload i need to add another object and an array inside the form object, I am wracking my brains but couldn't able to achieve it.
As you can see below 1 is the object that i am getting from form builder.
and 2. is the final object expected and i need to add "childrenCustomerIds" and "properties" respectively in the object after form builder object is created, but i have no clue how to add that.
Any help would be appreciated..
thanks in advance..!!!
1
{
"address": "string",
"customerId": "BGroup",
"email": "test#gmail.com",
"name": "Testing",
"parentCustomerId": "myCustomerId3",
"phoneNumber": "1111111111",
"primaryContactUserId": "primaryContactUserId",
"status": "ACTIVE",
"xylemPrimaryContactId": "testing"
}
2
{
"address": "string",
"childrenCustomerIds": ["testing"],
"customerId": "BGroup",
"email": "test#gmail.com",
"name": "Testing",
"parentCustomerId": "myCustomerId3",
"phoneNumber": "1111111111",
"primaryContactUserId": "primaryContactUserId",
"properties": {},
"status": "ACTIVE",
"xylemPrimaryContactId": "testing"
}
var obj={
"address": "string",
"customerId": "BGroup",
"email": "test#gmail.com",
"name": "Testing",
"parentCustomerId": "myCustomerId3",
"phoneNumber": "1111111111",
"primaryContactUserId": "primaryContactUserId",
"status": "ACTIVE",
"xylemPrimaryContactId": "testing"
}
Add "childrenCustomerIds": ["testing"]
Object.assign(obj, {"childrenCustomerIds": ["testing"]});
similarly you can add "properties": {}
Object.assign(obj, {"properties": {}});
I'm making an API call and the response I'm getting is a rather large JSON string. I'd like to minimise API calls to a) avoid hitting the rate limit and b) speed things up.
Here's an example of my JSON data:
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
My question:
What are my options with reference to persistent storage?
Please note: the API I'm using is in beta; so I'd like to avoid using MySQL for now because the JSON representation could change, resulting in my tables needing an overhaul.
I am working on an svg world map using highcharts and therefore I load the world map data using JSON as below:
$.getJSON('data.json', function (data) {...
JSON file that contains the below snippet but for all countries of the world.
[
{
"code": "AF",
"value": 53,
"name": "Afghanistan"
},
{
"code": "AL",
"value": 117,
"name": "Albania"
},
{
"code": "DZ",
"value": 15,
"name": "Algeria"
},
{
"code": "AS",
"value": 342,
"name": "American Samoa"
},
Highcharts generates the svg paths from this json data and each country path has a unique ID. How can I turn this highcharts generated map into a globe?
Thanks
What my overall aim is to have check-ins from a group of friends be displayed (most recent first) on a private web-app I am building.
Is this possible?
And if so, could someone kindly lead me in the right direction.
Thank you in advance :)
As long as they oAuth your application, you should be able to do this. You can't do this unless they explicitly allow you to for obvious security reasons. If you want a way around that, you can web scrape, but that is another issue entirely.
Take a look at their Real-Time API: https://developer.foursquare.com/overview/realtime
Create an application, then utilize their User Push API - every time one of them checks in, it should push something like this to your server:
{
"id": "4e6fe1404b90c00032eeac34",
"createdAt": 1315955008,
"type": "checkin",
"timeZone": "America/New_York",
"user": {
"id": "1",
"firstName": "Jimmy",
"lastName": "Foursquare",
"photo": "https://foursquare.com/img/blank_boy.png",
"gender": "male",
"homeCity": "New York, NY",
"relationship": "self"
},
"venue": {
"id": "4ab7e57cf964a5205f7b20e3",
"name": "foursquare HQ",
"contact": {
"twitter": "foursquare"
},
"location": {
"address": "East Village",
"lat": 40.72809214560253,
"lng": -73.99112284183502,
"city": "New York",
"state": "NY",
"postalCode": "10003",
"country": "USA"
},
"categories": [
{
"id": "4bf58dd8d48988d125941735",
"name": "Tech Startup",
"pluralName": "Tech Startups",
"shortName": "Tech Startup",
"icon": "https://foursquare.com/img/categories/building/default.png",
"parents": [
"Professional & Other Places",
"Offices"
],
"primary": true
}
],
"verified": true,
"stats": {
"checkinsCount": 7313,
"usersCount": 565,
"tipCount": 128
},
"url": "http://foursquare.com"
}
}
Best of luck to you!