I'm trying to get for example _id from this type of JSON:
[
{
"_id": 7,
"baalut": "פרטי",
"degem_cd": 558,
"degem_manoa": "CVK",
"degem_nm": "B8-8W2CDG",
"horaat_rishum": 160046,
"kinuy_mishari": "A4",
"kvutzat_zihum": 7,
"misgeret": "WAUZZZF46GA038023",
"mispar_rechev": 2623638,
"mivchan_acharon_dt": "2021-04-14T00:00:00",
"moed_aliya_lakvish": "2016-3",
"ramat_eivzur_betihuty": 1,
"ramat_gimur": "LUXURY DSN",
"rank": 0.0573088,
"shnat_yitzur": 2016,
"sug_degem": "P",
"sug_delek_nm": "בנזין",
"tokef_dt": "2022-03-08T00:00:00",
"tozeret_cd": 19,
"tozeret_nm": "אאודי",
"tzeva_cd": 80,
"tzeva_rechev": "שנהב לבן",
"zmig_ahori": "245/35 R19",
"zmig_kidmi": "245/35 R19"
}
]
Overall, this JSON response is long, So I'm removing the unnecessary.
This is my code:
const json = await response.json();
console.log(json.result.records);
I'm getting the result as shown before,
But now I want to get data inside the JSON,
So I tried to do json.result.records._id but it shows undefined
This is json.result:
{
"_links": {
"next": "/api/3/action/datastore_search?resource_id=053cea08-09bc-40ec-8f7a-156f0677aff3&q=2623638&limit=1&offset=1",
"start": "/api/3/action/datastore_search?resource_id=053cea08-09bc-40ec-8f7a-156f0677aff3&q=2623638&limit=1"
},
"fields": [
{
"id": "_id",
"type": "int"
},
{
"id": "mispar_rechev",
"info": [Object
],
"type": "numeric"
},
{
"id": "tozeret_cd",
"info": [Object
],
"type": "numeric"
},
{
"id": "sug_degem",
"info": [Object
],
"type": "text"
},
{
"id": "tozeret_nm",
"info": [Object
],
"type": "text"
},
{
"id": "degem_cd",
"info": [Object
],
"type": "numeric"
},
{
"id": "degem_nm",
"info": [Object
],
"type": "text"
},
{
"id": "ramat_gimur",
"info": [Object
],
"type": "text"
},
{
"id": "ramat_eivzur_betihuty",
"info": [Object
],
"type": "numeric"
},
{
"id": "kvutzat_zihum",
"info": [Object
],
"type": "numeric"
},
{
"id": "shnat_yitzur",
"info": [Object
],
"type": "numeric"
},
{
"id": "degem_manoa",
"info": [Object
],
"type": "text"
},
{
"id": "mivchan_acharon_dt",
"info": [Object
],
"type": "timestamp"
},
{
"id": "tokef_dt",
"info": [Object
],
"type": "timestamp"
},
{
"id": "baalut",
"info": [Object
],
"type": "text"
},
{
"id": "misgeret",
"info": [Object
],
"type": "text"
},
{
"id": "tzeva_cd",
"info": [Object
],
"type": "numeric"
},
{
"id": "tzeva_rechev",
"info": [Object
],
"type": "text"
},
{
"id": "zmig_kidmi",
"info": [Object
],
"type": "text"
},
{
"id": "zmig_ahori",
"info": [Object
],
"type": "text"
},
{
"id": "sug_delek_nm",
"info": [Object
],
"type": "text"
},
{
"id": "horaat_rishum",
"info": [Object
],
"type": "numeric"
},
{
"id": "moed_aliya_lakvish",
"info": [Object
],
"type": "text"
},
{
"id": "kinuy_mishari",
"info": [Object
],
"type": "text"
},
{
"id": "rank",
"type": "float"
}
],
"include_total": true,
"limit": 1,
"q": "2623638",
"records": [
{
"_id": 7,
"baalut": "פרטי",
"degem_cd": 558,
"degem_manoa": "CVK",
"degem_nm": "B8-8W2CDG",
"horaat_rishum": 160046,
"kinuy_mishari": "A4",
"kvutzat_zihum": 7,
"misgeret": "WAUZZZF46GA038023",
"mispar_rechev": 2623638,
"mivchan_acharon_dt": "2021-04-14T00:00:00",
"moed_aliya_lakvish": "2016-3",
"ramat_eivzur_betihuty": 1,
"ramat_gimur": "LUXURY DSN",
"rank": 0.0573088,
"shnat_yitzur": 2016,
"sug_degem": "P",
"sug_delek_nm": "בנזין",
"tokef_dt": "2022-03-08T00:00:00",
"tozeret_cd": 19,
"tozeret_nm": "אאודי",
"tzeva_cd": 80,
"tzeva_rechev": "שנהב לבן",
"zmig_ahori": "245/35 R19",
"zmig_kidmi": "245/35 R19"
}
],
"records_format": "objects",
"resource_id": "053cea08-09bc-40ec-8f7a-156f0677aff3",
"total": 1,
"total_estimation_threshold": null,
"total_was_estimated": false
}
You should be able to do json.result.records[0]._id, records is an array.
Related
I'm trying to change the ownership of a requested ERC721(NFT) to another wallet.
I'm using the Mumbai Test Net and ethers.
To do it I need to create the general ERC721 contract using its abi but I can't find it.
In comparison, the ERC20's abi I found easily - link and used it like followed and it's working:
const createERC20Contract = (contractAddress) => {
const provider = new ethers.providers.Web3Provider(ethereum);
const signer = provider.getSigner();
const ERC20Contract = new ethers.Contract(contractAddress, ERC20ABI, signer);
return ERC20Contract;
}
Where can I find the abi of ERC721 to create the ethers.Contract() ?
Here's a generic ERC721 ABI that I built from the OpenZeppelin implementation. (The bare minimum contract - none of their extensions such as mint and burn tokens.)
[
{
"inputs": [
{
"internalType": "string",
"name": "name_",
"type": "string"
},
{
"internalType": "string",
"name": "symbol_",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "approved",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "ApprovalForAll",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "approve",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "getApproved",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "isApprovedForAll",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "ownerOf",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "_data",
"type": "bytes"
}
],
"name": "safeTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"internalType": "bool",
"name": "approved",
"type": "bool"
}
],
"name": "setApprovalForAll",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "tokenURI",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
I have Avro Schema: customer record import the CustomerAddress subset.
[
{
"type": "record",
"namespace": "com.example",
"name": "CustomerAddress",
"fields": [
{ "name": "address", "type": "string" },
{ "name": "city", "type": "string" },
{ "name": "postcode", "type": ["string", "int"] },
{ "name": "type","type": {"type": "enum","name": "type","symbols": ["POBOX","RESIDENTIAL","ENTERPRISE"]}}
]
},
{
"type": "record",
"namespace": "com.example",
"name": "Customer",
"fields": [
{ "name": "first_name", "type": "string" },
{ "name": "middle_name", "type": ["null", "string"], "default": null },
{ "name": "last_name", "type": "string" },
{ "name": "age", "type": "int" },
{ "name": "height", "type": "float" },
{ "name": "weight", "type": "float" },
{ "name": "automated_email", "type": "boolean", "default": true },
{ "name": "customer_emails", "type": {"type": "array","items": "string"},"default": []},
{ "name": "customer_address", "type": "com.example.CustomerAddress" }
]
}
]
i have JSON payload:
{
"Customer" : {
"first_name": "John",
"middle_name": null,
"last_name": "Smith",
"age": 25,
"height": 177.6,
"weight": 120.6,
"automated_email": true,
"customer_emails": ["ning.chang#td.com", "test#td.com"],
"customer_address":
{
"address": "21 2nd Street",
"city": "New York",
"postcode": "10021",
"type": "RESIDENTIAL"
}
}
}
when i runt the command: java -jar avro-tools-1.8.2.jar fromjson --schema-file customer.avsc customer.json
got the following exception:
Exception in thread "main" org.apache.avro.AvroTypeException: Unknown union branch Customer
In your JSON data you use the key Customer but you have to use the fully qualified name. So it should be com.example.Customer.
Could you please help me understand if we can have multiple array properties in 1 vertex.. For example,
"id": "CU10611973PH",
"label": "Phone-Home",
"type": "vertex",
"properties": {
"PhonePreference": [
{
"id": "c63cf5c9-329b-456e-b94e-0c500587780f",
"value": "Primary"
}
],
"PhoneType": [
{
"id": "11f241d8-8e84-479b-b6a4-aeab7e039665",
"value": "Home"
}
],
"PhoneNumber": [
{
"id": "5795e2ec-6d8c-424c-b42d-f01b587caeca",
"value": "22222222222"
}
],
"pk": [
{
"id": "CU10611973PH|pk",
"value": "pk"
}
]
}
},
{
"id": "CU10611973PC",
"label": "Phone-cell",
"type": "vertex",
"properties": {
"PhonePreference": [
{
"id": "488c54b2-f256-4053-adc5-c07ec2e1a629",
"value": "Primary"
}
],
"PhoneType": [
{
"id": "2f5263e7-f42b-487f-a185-338682a68fdd",
"value": "Cell"
}
],
"PhoneNumber": [
{
"id": "a967516d-986c-4eac-929a-b86824677922",
"value": "123456789"
}
],
"pk": [
{
"id": "CU10611973PC|pk",
"value": "pk"
So here we are having 2 vertex, one for Phone-Home and one for Phone-Cell. Is there a way to make it come under 1 vertex with 2 set of properties .
I am using bot framework v4. I have developed a chatbot using .Net Core. The bot is integrated with LUIS and Qna Maker. One issue I am facing is that the bot duplicates the message that comes from the user. Please look at the screenshot below:
The replies I get from the bot are perfectly fine. The flow of the bot is as intended. I just cannot figure out why the message from user is being duplicated. I am using DirectLine for this. I will share whatever code part is needed.
{
"activities": [
{
"type": "message",
"id": "BR1wBZw7w2852JMLobk0EC-o|0000000",
"timestamp": "2019-12-02T19:41:57.1284328Z",
"channelId": "directline",
"from": {
"id": "CivicDevBot",
"name": "CivicChat"
},
"conversation": {
"id": "BR1wBZw7w2852JMLobk0EC-o"
},
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "Image",
"size": "large",
"url": "https://i.imgur.com/ViaEUnA.png"
}
]
}
],
"horizontalAlignment": "Center"
},
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"items": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"color": "light",
"text": "Welcome to CIVIC Financial Services",
"wrap": true
},
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"color": "light",
"text": "I am S.U.E",
"wrap": true
},
{
"type": "TextBlock",
"color": "light",
"text": "I can help you answer your questions. Familiarize yourself with CIVIC Financial Services.",
"wrap": true
},
{
"type": "TextBlock",
"color": "light",
"text": "If you want to talk to a Customer Service Agent, just type \"I want to talk to a Customer Service Agent\".",
"wrap": true
}
],
"separator": true,
"horizontalAlignment": "Left"
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"data": {
"action": "aboutCivic"
},
"title": "About CIVIC"
},
{
"type": "Action.ShowCard",
"card": {
"type": "AdaptiveCard",
"actions": [
{
"type": "Action.ShowCard",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "We are open from Monday through Friday from 8:00am to 6:00pm.",
"wrap": true
}
],
"style": "emphasis"
},
"title": "When are you open?"
},
{
"type": "Action.ShowCard",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "Image",
"size": "stretch",
"url": "https://i.imgur.com/gBVgI25.png",
"horizontalAlignment": "center"
},
{
"type": "TextBlock",
"text": "AZ, CA, CO, FL, GA, HI, NC, NV, OR, SC, TN, TX, UT, VA & WA",
"wrap": true
}
],
"style": "emphasis"
},
"title": "Do you have an office near me? "
},
{
"type": "Action.ShowCard",
"card": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": "8 to 10 days, it all depends on how it takes to get access to the property.",
"wrap": true
}
],
"style": "emphasis"
},
"title": "How quickly can we close? "
}
],
"style": "emphasis"
},
"title": "FAQs"
}
]
}
}
],
"entities": [],
"replyToId": "8WGOnspSxN3"
},
{
"type": "message",
"id": "BR1wBZw7w2852JMLobk0EC-o|0000001",
"timestamp": "2019-12-02T19:43:39.96502Z",
"serviceUrl": "https://directline.botframework.com/",
"channelId": "directline",
"from": {
"id": "r_1575315715",
"name": "",
"role": "user"
},
"conversation": {
"id": "BR1wBZw7w2852JMLobk0EC-o"
},
"textFormat": "plain",
"locale": "en-GB",
"text": "teeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"entities": [
{
"type": "ClientCapabilities",
"requiresBotState": true,
"supportsListening": true,
"supportsTts": true
}
],
"channelData": {
"siteDomain": "https://websiteae1.stackblitz.io/"
}
},
{
"type": "message",
"id": "BR1wBZw7w2852JMLobk0EC-o|0000002",
"timestamp": "2019-12-02T19:43:41.7278914Z",
"channelId": "directline",
"from": {
"id": "CivicDevBot",
"name": "CivicChat"
},
"conversation": {
"id": "BR1wBZw7w2852JMLobk0EC-o"
},
"text": "Sorry, I didn't understand. Consider rephrasing your question or contacting a customer agent",
"attachments": [],
"entities": [],
"replyToId": "BR1wBZw7w2852JMLobk0EC-o|0000001"
},
{
"type": "message",
"id": "BR1wBZw7w2852JMLobk0EC-o|0000003",
"timestamp": "2019-12-02T20:00:25.784598Z",
"serviceUrl": "https://directline.botframework.com/",
"channelId": "directline",
"from": {
"id": "r_1575315715",
"name": "",
"role": "user"
},
"conversation": {
"id": "BR1wBZw7w2852JMLobk0EC-o"
},
"textFormat": "plain",
"locale": "en-GB",
"text": "helo",
"channelData": {
"siteDomain": "https://websiteae1.stackblitz.io/"
}
},
{
"type": "message",
"id": "BR1wBZw7w2852JMLobk0EC-o|0000004",
"timestamp": "2019-12-02T20:00:26.5739342Z",
"channelId": "directline",
"from": {
"id": "CivicDevBot",
"name": "CivicChat"
},
"conversation": {
"id": "BR1wBZw7w2852JMLobk0EC-o"
},
"text": "Sorry, I didn't understand. Consider rephrasing your question or contacting a customer agent",
"attachments": [],
"entities": [],
"replyToId": "BR1wBZw7w2852JMLobk0EC-o|0000003"
},
{
"type": "message",
"id": "BR1wBZw7w2852JMLobk0EC-o|0000005",
"timestamp": "2019-12-02T20:00:27.3293896Z",
"serviceUrl": "https://directline.botframework.com/",
"channelId": "directline",
"from": {
"id": "r_1575315715",
"name": "",
"role": "user"
},
"conversation": {
"id": "BR1wBZw7w2852JMLobk0EC-o"
},
"textFormat": "plain",
"locale": "en-GB",
"text": "hello",
"channelData": {
"siteDomain": "https://websiteae1.stackblitz.io/"
}
},
{
"type": "message",
"id": "BR1wBZw7w2852JMLobk0EC-o|0000006",
"timestamp": "2019-12-02T20:00:27.6064185Z",
"channelId": "directline",
"from": {
"id": "CivicDevBot",
"name": "CivicChat"
},
"conversation": {
"id": "BR1wBZw7w2852JMLobk0EC-o"
},
"text": "Hello",
"inputHint": "acceptingInput",
"attachments": [],
"entities": [],
"replyToId": "BR1wBZw7w2852JMLobk0EC-o|0000005"
}
],
"watermark": "6"
}
I want to retrieve the different tag values in an NSString.
NSString *test =
{
"data": [
{
"id": "100002319144563_125257217561582",
"from": {
"name": "Umair Ahmed",
"id": "100002319144563"
},
"message": "Hello Umair Here",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/100002319144563/posts/125257217561582"
},
{
"name": "Like",
"link": "http://www.facebook.com/100002319144563/posts/125257217561582"
}
],
"privacy": {
"description": "Everyone",
"value": "EVERYONE"
},
"type": "status",
"application": {
"name": "iPhone",
"id": "213257025359930"
},
"created_time": "2011-07-08T11:59:15+0000",
"updated_time": "2011-07-08T11:59:15+0000"
},
{
"id": "100002319144563_125251050895532",
"from": {
"name": "Umair Ahmed",
"id": "100002319144563"
},
"message": "Hello testing testing",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/100002319144563/posts/125251050895532"
},
{
"name": "Like",
"link": "http://www.facebook.com/100002319144563/posts/125251050895532"
}
]
}
]
}
How can I retrieve the name and message tag values into an array or dictionary?
It looks like a JSON string, so just use one of JSON libraries, like TouchJSON or JSONKit and you can easily extract the data from the structures they will provide you.