The error i am getting is this : Can't parse fields attribute. Is it a JSON array or CSV list?
The problem is in the select menu which is being included in the form. what i want to achieve is a select box as shown here on this link : Registration plugin
But somehow the problem is that the select box is not being displayed!
<iframe src='http://www.facebook.com/plugins/registration.php?
client_id=325340244194060&
redirect_uri=http://www.pingcampus.com/facebook_registration_plugin/store_user_data.php&
fields=[
{"name":"name"},
{"name":"email"},
{"name":"gender"},
{"name":"birthday"},
{'name':'captain', 'description':'Best Captain', 'type':'select', 'options':{'P':'Jean-Luc Picard','K':'James T. Kirk'}}
{'name':'captain', 'description':'College','type':'select','options':
{'P':'Jean-Luc Picard','K':'James T. Kirk',
'1':'Acropolis','2':'Astral','3':'Aurobindo','4':'BM','5':'Central','6':'Chameli','7':'IET (DAVV)','8':'IIST
','9':'IIST2
','10':'IPS
','11':'JDCT
','12':'KCB
','13':'LKCT
','14':'LNCT
','15':'MIT (Malwa)
','16':'Malwa (Malwa2)
','17':'Mandsaur
','18':'Mathuradevi
','19':'MITM (Medi1)
','20':'MIST (Medi2)
','21':'MGIEM
','22':'Nalin
','23':'Oriental
','24':'Patel
','25':'Prestige
','26':'Priyatam
','27':'Rishiraj
','28':'RKDF
','29':'Royal
','30':'Sanghvi
','31':'Sdbansal
','32':'SGSITS
','33':'SIMS
','34':'SKSITS
','35':'Star
','36':'SVCE
','37':'SVITS
','38':'Transnational
','39':'Truba
','40':'Venkateshwar
','41':'Vidhyasagar
','42':'Vikrant
','43':'Vindhya
','#':'--------------------------------
','#':'Commerce
','#':'--------------------------------
','44':'Acro
','45':'Apex
','46':'Arihant
','47':'BM
','48':'Chamelidevi
','49':'Chimc
','50':'Choithram
','51':'Christian
','52':'DCBS (Daly College)
','53':'IBMR
','54':'IIMR (IIST)
','55':'IIPS (DAVV)
','56':'Ilva
','57':'IMIR
','58':'Imperial
','59':'IMS (DAVV)
','60':'Islamia
','61':'JDCT
','62':'LKCT
','63':'LNCT
','64':'Maharaja
','65':'MIT (Malwa)
','66':'Mathuradevi
','67':'Matushri
','68':'MBKhalsa
','69':'Medicaps
','70':'Patel
','71':'Pioneer
','72':'Prestige
','73':'Priyatam
','74':'Renaissance
','75':'Rishiraj
','76':'Sahib
','77':'SAIMS
','78':'Sanghvi Innovative
','79':'Sapient
','80':'SGSITS
','81':'SIMS
','82':'SJDM
','83':'SKSITS
','84':'Softvision
','85':'SVCE
','86':'Rransnational
','87':'Vaishnav
','88':'Venkteshwar
','89':'Vidhyasagar
','90':'Vikrant
','#':'--------------------------------
','#':'Pharmacy
','#':'--------------------------------
','91':'Acropolis
','92':'Aurobindo
','93':'BM
','94':'Central
','95':'SOPE (DAVV)
','96':'IIP(IIST)
','97':'IPS
','98':'Oriental
','99':'Rishiraj
','100':'RKDF
','101':'Safe
','102':'SGSITS
','103':'Smriti (SCOPE)
','104':'svce
','105':'vikrant
','#':'--------------------------------
','#':'Medical
','#':'--------------------------------
','106':'Arihant
','107':'Bombay Hospital
','108':'Index
','109':'MGMMC
','110':'RD Memorial
','111':'Shubhdeep
','#':'--------------------------------
','#':'Dental
','#':'--------------------------------
','112':'Aurobindo
','113':'CDSH
','114':'GCD
','115':'Index
','116':'Modern
','#':'--------------------------------
','#':'Arts
','#':'--------------------------------
','117':'BIG Aims
','118':'Frameboxx
','119':'INIFD
','120':'MAAC
','121':'SDPS
','122':'SJMC (DAVV)
','123':'Virtual Voyage
','124':'Zica
','132':'EMRC (DAVV)
','#':'--------------------------------
','#':'Architecture
','#':'--------------------------------
','125':'IPS
','126':'SDPS
','#':'--------------------------------
','#':'Law
','#':'--------------------------------
','127':'Christian
','128':'SOL(DAVV)
','129':'IIL
','130':'Vaishnav'} },
{"name":"Arts","description":"Arts","type":"checkbox","value":"Arts"},
{"name":"Act","description":"Act","type":"checkbox","value":"Act"},
{"name":"Cooking","description":"Cooking","type":"checkbox","value":"Cooking"},
{"name":"Dance","description":"Dance","type":"checkbox","value":"Dance"},
{"name":"Designing","description":"Designing","type":"checkbox","value":"Designing"},
{"name":"Fashion","description":"Fashion Designing","type":"checkbox","value":"Fashion Designing"},
{"name":"Interior","description":"Interior Designing","type":"checkbox","value":"Interior Designing"},
{"name":"Modeling","description":"Modeling","type":"checkbox","value":"Modeling"},
{"name":"Photography","description":"Photography","type":"checkbox","value":"Photography"},
{"name":"Poetry","description":"Poetry / Writing","type":"checkbox","value":"Poetry / Writing"},
{"name":"Programming","description":"Programming","type":"checkbox","value":"Programming"},
{"name":"Reading","description":"Reading","type":"checkbox","value":"Reading"},
{"name":"Sketching","description":"Sketching / Drawing","type":"checkbox","value":"Sketching / Drawing"},
{"name":"Singing","description":"Singing","type":"checkbox","value":"Singing"},
{"name":"Sports","description":"Sports","type":"checkbox","value":"Sports"},
{"name":"Stunting","description":"Stunting","type":"checkbox","value":"Stunting"},
{"name":"Videography","description":"Checkthis","type":"checkbox","value":"Videography"},
{"name":"Other","description":"Other","type":"checkbox","value":"Other"},
{"name":"captcha"}
]'
scrolling="auto"
frameborder="no"
style="border:none"
allowTransparency="true"
width="500"
height="800"
>
</iframe>
Try to replace fields=[....] with valid JSON
[
{
"name": "name"
},
{
"name": "email"
},
{
"name": "gender"
},
{
"name": "birthday"
},
{
"name": "captain",
"description": "BestCaptain",
"type": "select",
"options": {
"P": "Jean-LucPicard",
"K": "JamesT.Kirk"
}
},
{
"name": "captain",
"description": "College",
"type": "select",
"options": {
"1": "Acropolis",
"2": "Astral",
"3": "Aurobindo",
"4": "BM",
"5": "Central",
"6": "Chameli",
"7": "IET(DAVV)",
"8": "IIST",
"9": "IIST2",
"10": "IPS",
"11": "JDCT",
"12": "KCB",
"13": "LKCT",
"14": "LNCT",
"15": "MIT(Malwa)",
"16": "Malwa(Malwa2)",
"17": "Mandsaur",
"18": "Mathuradevi",
"19": "MITM(Medi1)",
"20": "MIST(Medi2)",
"21": "MGIEM",
"22": "Nalin",
"23": "Oriental",
"24": "Patel",
"25": "Prestige",
"26": "Priyatam",
"27": "Rishiraj",
"28": "RKDF",
"29": "Royal",
"30": "Sanghvi",
"31": "Sdbansal",
"32": "SGSITS",
"33": "SIMS",
"34": "SKSITS",
"35": "Star",
"36": "SVCE",
"37": "SVITS",
"38": "Transnational",
"39": "Truba",
"40": "Venkateshwar",
"41": "Vidhyasagar",
"42": "Vikrant",
"43": "Vindhya",
"44": "Acro",
"45": "Apex",
"46": "Arihant",
"47": "BM",
"48": "Chamelidevi",
"49": "Chimc",
"50": "Choithram",
"51": "Christian",
"52": "DCBS(DalyCollege)",
"53": "IBMR",
"54": "IIMR(IIST)",
"55": "IIPS(DAVV)",
"56": "Ilva",
"57": "IMIR",
"58": "Imperial",
"59": "IMS(DAVV)",
"60": "Islamia",
"61": "JDCT",
"62": "LKCT",
"63": "LNCT",
"64": "Maharaja",
"65": "MIT(Malwa)",
"66": "Mathuradevi",
"67": "Matushri",
"68": "MBKhalsa",
"69": "Medicaps",
"70": "Patel",
"71": "Pioneer",
"72": "Prestige",
"73": "Priyatam",
"74": "Renaissance",
"75": "Rishiraj",
"76": "Sahib",
"77": "SAIMS",
"78": "SanghviInnovative",
"79": "Sapient",
"80": "SGSITS",
"81": "SIMS",
"82": "SJDM",
"83": "SKSITS",
"84": "Softvision",
"85": "SVCE",
"86": "Rransnational",
"87": "Vaishnav",
"88": "Venkteshwar",
"89": "Vidhyasagar",
"90": "Vikrant",
"91": "Acropolis",
"92": "Aurobindo",
"93": "BM",
"94": "Central",
"95": "SOPE(DAVV)",
"96": "IIP(IIST)",
"97": "IPS",
"98": "Oriental",
"99": "Rishiraj",
"100": "RKDF",
"101": "Safe",
"102": "SGSITS",
"103": "Smriti(SCOPE)",
"104": "svce",
"105": "vikrant",
"106": "Arihant",
"107": "BombayHospital",
"108": "Index",
"109": "MGMMC",
"110": "RDMemorial",
"111": "Shubhdeep",
"112": "Aurobindo",
"113": "CDSH",
"114": "GCD",
"115": "Index",
"116": "Modern",
"117": "BIGAims",
"118": "Frameboxx",
"119": "INIFD",
"120": "MAAC",
"121": "SDPS",
"122": "SJMC(DAVV)",
"123": "VirtualVoyage",
"124": "Zica",
"125": "IPS",
"126": "SDPS",
"127": "Christian",
"128": "SOL(DAVV)",
"129": "IIL",
"130": "Vaishnav",
"132": "EMRC(DAVV)",
"P": "Jean-LucPicard",
"K": "JamesT.Kirk",
"#": "--------------------------------"
}
},
{
"name": "Arts",
"description": "Arts",
"type": "checkbox",
"value": "Arts"
},
{
"name": "Act",
"description": "Act",
"type": "checkbox",
"value": "Act"
},
{
"name": "Cooking",
"description": "Cooking",
"type": "checkbox",
"value": "Cooking"
},
{
"name": "Dance",
"description": "Dance",
"type": "checkbox",
"value": "Dance"
},
{
"name": "Designing",
"description": "Designing",
"type": "checkbox",
"value": "Designing"
},
{
"name": "Fashion",
"description": "Fashion Designing",
"type": "checkbox",
"value": "Fashion Designing"
},
{
"name": "Interior",
"description": "Interior Designing",
"type": "checkbox",
"value": "Interior Designing"
},
{
"name": "Modeling",
"description": "Modeling",
"type": "checkbox",
"value": "Modeling"
},
{
"name": "Photography",
"description": "Photography",
"type": "checkbox",
"value": "Photography"
},
{
"name": "Poetry",
"description": "Poetry / Writing",
"type": "checkbox",
"value": "Poetry / Writing"
},
{
"name": "Programming",
"description": "Programming",
"type": "checkbox",
"value": "Programming"
},
{
"name": "Reading",
"description": "Reading",
"type": "checkbox",
"value": "Reading"
},
{
"name": "Sketching",
"description": "Sketching / Drawing",
"type": "checkbox",
"value": "Sketching / Drawing"
},
{
"name": "Singing",
"description": "Singing",
"type": "checkbox",
"value": "Singing"
},
{
"name": "Sports",
"description": "Sports",
"type": "checkbox",
"value": "Sports"
},
{
"name": "Stunting",
"description": "Stunting",
"type": "checkbox",
"value": "Stunting"
},
{
"name": "Videography",
"description": "Checkthis",
"type": "checkbox",
"value": "Videography"
},
{
"name": "Other",
"description": "Other",
"type": "checkbox",
"value": "Other"
},
{
"name": "captcha"
}
]
Your fields parameter for Registration social plugin contain not valid JSON object (JSON should use double quotes instead of single quotes) and you're missing , (comma) in the middle of array, after next line:
{'name':'captain', 'description':'Best Captain', 'type':'select', 'options':{'P':'Jean-Luc Picard','K':'James T. Kirk'}}
Update:
Actually even usage of just valid JSON may not work in that case due to fact that this is passed as query string arguments, so that JSON should be properly encoded to avoid problems. Also may cause some issues.
Also you have two fields named "captain" (which cause problem with registration plugin too).
Here I've created some samples (due to massive code of fields, I'm not putting them here):
Creating fields from JavaScript object and passing em to Registration plugin: http://jsfiddle.net/QwdCv/
Correctly encoded fields in URL passed directly within iframe tag src attribute: http://jsfiddle.net/QwdCv/1/
Related
I have the following data and I want to wrap the OPTIONAL array as an object and then put in as a union but since I am new to this, I am not sure how to do this.
This is how I have done so far so could someone help me correct the below structure in the expected output. Note that this dataRefs is an optional field and this entire structure may or may not be present.
{
"name": "dataRefs",
"default": null,
"type": ["null",
{
"type": "array",
"items": {
"name": "dataRef",
"type": "record",
"fields": [
{
"name": "dataId",
"type": "string",
"avro.java.string": "String"
},
{
"name": "email",
"type": ["null" ,"string"],
"avro.java.string": "String"
},
{
"name": "phone",
"type": ["null" ,"string"],
"avro.java.string": "String"
},
{
"name": "userName",
"type": ["null" ,"string"],
"avro.java.string": "String"
},
{
"name": "addressRef",
"default": null,
"type": ["null", {
"name": "addressRefRecord",
"type": "record",
"fields": [
{
"name": "addrRefId",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "addrType",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "addressLine1",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "addressLine2",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "city",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "province",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "country",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "postalCode",
"type": ["null","string"],
"avro.java.string": "String"
}
]
}
]
}
]
}
}
]
}
My JSON data that I intend to map to above schema looks like follows:
"dataRefs": [{
"addressRef": {
"addrRefId": "0",
"addrType": "ADDRESS",
"addressLine1": "DA 81",
"addressLine2": "",
"city": "Amsterdam",
"country": "Netherlands",
"postalCode": "xxxx LN",
"province": ""
},
"dataId": "0",
"email": "xyz#abc.com"
}],
This is how I was able to do so:
{
"name": "dataRefs",
"type": [
"null",
{
"type": "record",
"name": "dataRefsObject",
"fields": [
{
"name": "dataRefsArray",
"type": {
"type": "array",
"items": {
"name": "dataRef",
"type": "record",
"fields": [
{
"name": "dataId",
"type": ["null", "string"],
"avro.java.string": "String"
},
{
"name": "userName",
"type": [
"null",
"string"
],
"avro.java.string": "String"
},
....
Here is the full json that I want to parse and extract the text that has the value: The product is in second line 3rd row.
Can someone help?
"activities": [
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:56.8251462Z",
"serviceUrl": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"channelId": "directline",
"from": {
"id": "user1"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"text": "the milk"
},
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:57.6856172Z",
"localTimestamp": "2019-07-01T15:18:57.5099359+00:00",
"channelId": "directline",
"from": {
"id": "XXXXXX",
"name": "XXXXXX"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXX"
},
"text": "The product is in second line 3rd row",
"attachments": [],
"entities": [],
"replyToId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
],
"watermark": "1"
}
You have specified that this is a full json you have placed in the question, But it is not full json you are missing something.
"activities":
[ //json array start from here
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:56.8251462Z",
"serviceUrl": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"channelId": "directline",
"from": {
"id": "user1"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"text": "the milk"
},
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:57.6856172Z",
"localTimestamp": "2019-07-01T15:18:57.5099359+00:00",
"channelId": "directline",
"from": {
"id": "XXXXXX",
"name": "XXXXXX"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXX"
},
"text": "The product is in second line 3rd row",
"attachments": [],
"entities": [],
"replyToId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
], //json array ends here
these are extra lines
***"watermark": "1"
}***
if you want to use this array you need to add a '{' in very top line before
"activities": [
I am placing here a valid json now you can check it on Json parser used to parse json in objects
*Valid Json Here : *
{
"activities": [
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:56.8251462Z",
"serviceUrl": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"channelId": "directline",
"from": {
"id": "user1"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"text": "the milk"
},
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:57.6856172Z",
"localTimestamp": "2019-07-01T15:18:57.5099359+00:00",
"channelId": "directline",
"from": {
"id": "XXXXXX",
"name": "XXXXXX"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXX"
},
"text": "The product is in second line 3rd row",
"attachments": [],
"entities": [],
"replyToId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
],
"watermark": "1"
}
How can I extract only the objects id and name from this JSON via jq?
The output should be look like the format below. This is just an example for the required output, the real one that I need is to catch the whole values id and name like in the JSON source.
This is the required output:
{
"name": "Auto Body Styles",
"id": "1.1"}
{
"name": "Convertible",
"id": "1.1.2"
}
This is the JSON source file:
{
"name": "Automotive",
"id": "1",
"categories": [
{
"name": "Auto Body Styles",
"id": "1.1",
"categories": [
{
"name": "Commercial Trucks",
"id": "1.1.1"
},
{
"name": "Convertible",
"id": "1.1.2"
},
{
"name": "Coupe",
"id": "1.1.3"
},
{
"name": "Crossover",
"id": "1.1.4"
},
{
"name": "Hatchback",
"id": "1.1.5"
},
{
"name": "Microcar",
"id": "1.1.6"
},
{
"name": "Minivan",
"id": "1.1.7"
},
{
"name": "Off-Road Vehicles",
"id": "1.1.8"
},
{
"name": "Pickup Trucks",
"id": "1.1.9"
},
{
"name": "Sedan",
"id": "1.1.10"
},
{
"name": "Station Wagon",
"id": "1.1.11"
},
{
"name": "SUV",
"id": "1.1.12"
},
{
"name": "Van",
"id": "1.1.13"
}
]
},
{
"name": "Auto Buying and Selling",
"id": "1.2"
},
{
"name": "Auto Insurance",
"id": "1.3"
},
{
"name": "Auto Parts",
"id": "1.4"
},
{
"name": "Auto Recalls",
"id": "1.5"
},
{
"name": "Auto Repair",
"id": "1.6"
},
{
"name": "Auto Safety",
"id": "1.7"
},
{
"name": "Auto Shows",
"id": "1.8"
},
{
"name": "Auto Technology",
"id": "1.9",
"categories": [
{
"name": "Auto Infotainment Technologies",
"id": "1.9.1"
},
{
"name": "Auto Navigation Systems",
"id": "1.9.2"
},
{
"name": "Auto Safety Technologies",
"id": "1.9.3"
}
]
},
{
"name": "Auto Type",
"id": "1.10",
"categories": [
{
"name": "Budget Cars",
"id": "1.10.1"
},
{
"name": "Certified Pre-Owned Cars",
"id": "1.10.2"
},
{
"name": "Classic Cars",
"id": "1.10.3"
},
{
"name": "Concept Cars",
"id": "1.10.4"
},
{
"name": "Driverless Cars",
"id": "1.10.5"
},
{
"name": "Green Vehicles",
"id": "1.10.6"
}
]
} ] }
i think what you want is Recursive Descent: ..
cat car.json | jq -r '.. | [.name?, .id?] | select(length>0) | #tsv'
to produce something like in your example,
cat car.json | jq -r '.. | {name:.name?, id:.id?}'
I have this schema for a json response
{
"title": "Products",
"description": "schema for products",
"type": "array",
"properties": {
"id": {
"description": "id of a product",
"type": "integer"
},
"name": {
"description": "name of the product",
"type": "string"
},
"created_at": {
"description": "record created_at",
"type": "string",
"format": "date-time"
},
"updated_at": {
"description": "record updated_at",
"type": "string",
"format": "date-time"
}
},
"required": ["id", "name"]
}
and I want to match this schema with this json
[{
"id": 1,
"name": "Cricket Ball"
}, {
"id": 2,
"name": "Soccer Ball"
}, {
"id": 3,
"name": "football ball"
}, {
"id": 4,
"name": "Basketball ball"
}, {
"id": 5,
"name": "Table Tennis ball"
}, {
"id": 6,
"name": "Tennis ball"
}]
This schema matches the response but it also matches the schema in which the required field is this
"required": ["ids", "names"]
I think the schema is validated against the array and the objects in the array are not validated.
The way you have it set up now, your properties key refers to the array itself, not to each item, and is being ignored (because arrays don't have properties, they just have items). You need to use the items key to validate each item in the array, like so:
{
"title": "Products",
"description": "schema for products",
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"description": "id of a product",
"type": "integer"
},
"name": {
"description": "name of the product",
"type": "string"
},
"created_at": {
"description": "record created_at",
"type": "string",
"format": "date-time"
},
"updated_at": {
"description": "record updated_at",
"type": "string",
"format": "date-time"
}
},
"required": ["id", "name"]
}
}
try map
new_array = response.map{ |k| { 'id': k['properties']['id']['description'], 'name': k['properties']['name']['description'] } }
I'm trying to loop through a multi-dimensional array to get properties of products that are part of line items. They look basically like this: (I did a json_encode so it would be easier to read)
[{
"rcpt": "email#email.com",
"vars": [{
"name": "SYSTEM",
"content": "Bikes"
}, {
"name": "CUSTOMERSERVICE",
"content": "(855-553-4889)"
}, {
"name": "IMAGE",
"content": "http:\/\/www.url.com\/assets\/images\/chicago\/email\/dear_member.jpg"
}, {
"name": "LINKCOLOR",
"content": "#3db7e4"
}, {
"name": "FACEBOOK",
"content": "Bikes"
}, {
"name": "TWITTER",
"content": "Bikes"
}, {
"name": "INSTAGRAM",
"content": "Bikes"
}, {
"name": "CLOSING",
"content": "Greetings"
}, {
"name": "item",
"content": [{
"lineItem": 1,
"id": "3",
"name": "24-Hour Pass Gift Certificate",
"quantity": 2,
"nameShort": "24-Hour",
"type": "Gift Certificate",
"image": "24hour_blank.jpg",
"price": "9.95",
"total": "19.90",
"taxable": false,
"giftCertificates": {
"3204": {
"id": "3204",
"redemptionNumber": "xxxxx",
"type": "24-Hour"
},
"3205": {
"id": "3205",
"redemptionNumber": "xxxxx",
"type": "24-Hour"
}
}
}, {
"lineItem": 2,
"id": "1",
"name": "Annual Membership Gift Certificate",
"quantity": 2,
"nameShort": "Annual",
"type": "Gift Certificate",
"image": "annual_blank.jpg",
"price": "75.00",
"total": "150.00",
"taxable": false,
"giftCertificates": {
"892": {
"id": "892",
"redemptionNumber": "xxxxxx",
"type": "Annual"
},
"893": {
"id": "893",
"redemptionNumber": "xxxxx",
"type": "Annual"
}
}
}]
}, {
"name": "orderID",
"content": 1220
}, {
"name": "giftMessage",
"content": false
}, {
"name": "email",
"content": "email#email.com"
}, {
"name": "transactionDate",
"content": "12\/23\/2015"
}, {
"name": "transactionTime",
"content": "12:21 pm"
}, {
"name": "salesTaxTotal",
"content": 0
}, {
"name": "salesTaxRatePercent",
"content": "6.250"
}, {
"name": "TransactionAmount",
"content": "169.90"
}, {
"name": "account_number",
"content": "XXXX1111"
}, {
"name": "card_type",
"content": "Visa"
}, {
"name": "firstName",
"content": "tetete"
}, {
"name": "lastName",
"content": "tethuhhu"
}, {
"name": "address",
"content": "295 Place St"
}, {
"name": "city",
"content": "Brooklyn"
}, {
"name": "state",
"content": "NY"
}, {
"name": "zip",
"content": "11238"
}, {
"name": "country",
"content": "US"
}, {
"name": "phone",
"content": "8888888888"
}, {
"name": "transactionId",
"content": "xxxxxx"
}, {
"name": "shipToFirstName",
"content": "tetete"
}, {
"name": "shipToLastName",
"content": "tethuhhu"
}, {
"name": "shipToAaddress",
"content": "295 Place St"
}, {
"name": "shipToCity",
"content": "Brooklyn"
}, {
"name": "shipToState",
"content": "NY"
}, {
"name": "shipToZipCode",
"content": "11238"
}, {
"name": "ShipToCountry",
"content": "US"
}, {
"name": "ShipToCountry",
"content": "US"
}]
}]
So I am trying to get a print out of each gift certificate's type and redemption number. When I iterate through {{ giftCertificates }} like this:
{{#each giftCertificates}}
{{type}} {{redemptionNumber}}
{{/each}}
I get one of the line items but not the other. I'm guessing maybe it is being overwritten when it loops through again? But I have also tried to loop through {{ item }} and grab {{ giftCertificates.type }} and {{ giftCertificates.redemptionNumber }} and that does not work either. What is the correct way to get all of these from each line item?
Thanks for your help.
I know this is a very old question, but:
you can use {{this.proprietyName}} to get the type and number:
{{#each giftCertificates}}
{{this.892.type}}
{{/each}}
do not forget to add this to the mandrill message o
"merge": true,
"merge_language": "handlebars",
Also, the data structure is not ideal:
giftCertificates[
{
"id": "892",
"redemptionNumber": "xxxxxx",
"type": "Annual"
},
{
"id": "893",
"redemptionNumber": "xxxxxx",
"type": "Annual"
}
]
would be easier to handle.