Get specific object from JSONPath array result after predicate is applied - arrays

In JSONPath 0.9.1 the following Json path was valid:
http://jsonpath.herokuapp.com/?path=$.store.book[?(#.author==%27Nigel%20Rees%27)][0]
returning
{
"category" : "reference",
"author" : "Nigel Rees",
"title" : "Sayings of the Century",
"price" : 8.95
}
I've upgraded to the latest one (2.3) and the query now returns empty array.
Is this a bug or the way to retrieve an element from the resulting array has changed?

Given this document:
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
Using JsonPath 2.3.0, the following code returns a JSONArray (rather than an Object[]):
JsonPath.parse(JSON).read("$.store.book[?(#.author==\"Nigel Rees\")]");
So, the following code ...
JSONArray read = JsonPath.parse(JSON).read("$.store.book[?(#.author==\"Nigel Rees\")]");
System.out.println(read.get(0));
... will print:
{category=reference, author=Nigel Rees, title=Sayings of the Century, price=8.95}

Related

Filtering JSON data in a list

I am new to working with JSON data. I am having difficulty on how to return back bicycles that have a color of "Blue". Using JSONPath.
The following example JSON file.
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
"bicycle": [
{
"price": 19.95
"color": [
"red"
],
},
{
"price": 20.99
"color": [
"blue",
"Green"
],
},
]
}
}
I have tried to use the following filter but it doesn't work.
$.store.bicycle[?(#.color=='blue')]
Any ideas to how to get this to work and only return the price of bicycles that are Blue?
Any information is greatly welcomed.
The JSON Data is
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
}],
"bicycle": [
{
"price": 19.95,
"color": [
"red"
]
},
{
"price": 20.99,
"color": [
"blue",
"Green"
]
}
]
}
}
The JSONPath is
$.store.bicycle[?(#.color.indexOf('blue') != -1)]

Update array element using JsonPath

I am trying to replace a certain element in an a Json array using jayway's JsonPath in Java. Example:
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
Here I'd like to be able to replace the first book in the array. I can find the element by using this query $.store.book.[?(#.author =='Nigel Rees')]
I then use this code to replace the this node:
Configuration configuration = Configuration.builder()
.jsonProvider(new JacksonJsonNodeJsonProvider())
.mappingProvider(new JacksonMappingProvider())
.build();
DocumentContext pbContext = JsonPath.using(configuration).parse(theAboveJson);
pbContext.set("$.store.book.[?(#.author =='Nigel Rees')]", someOtherJson);
But I noticed that instead of replacing, the new node is inserted at position 0 in the books array. Is there any way to actually replace the array element?

Sorting arrays in Mongo

H have json document with array. As I can't add to beginning of array with push or addtoset I need to sort array. Example
{
"Component": [
{
"Id": "PDP-1",
"Links": {"Link": [
{
"Text": "Western Division",
"Url": "/1x7-en70ai/last-minute-holidays-western-division",
"Title": "Last minute holidays Western Division"
},
{
"Text": "Browse Regions ",
"Url": "/1x7-en6uly-10ts/last-minute-holidays-gambia/regions",
"Title": "Last minute holidays Gambia",
"Style": "BrowseForMore"
},
{
"Text": "City of Banjul",
"Url": "/1x6-en6vq7/holidays-city-of-banjul",
"Title": "City of Banjul Holidays"
},
{
"Text": "Western Division",
"Url": "/1x6-en70ai/holidays-western-division",
"Title": "Western Division Holidays"
}
]},
"Title": "Regions",
"Type": "PDP"
},
{
"Id": "PDP-2",
"Links": {"Link": [
{
"Text": "Bijilo",
"Url": "/1x7-enbmy6/last-minute-holidays-bijilo",
"Title": "Last minute holidays Bijilo"
},
{
"Text": "Browse Cities ",
"Url": "/1x7-en6uly-10tt/last-minute-holidays-gambia/cities",
"Title": "Last minute holidays Gambia",
"Style": "BrowseForMore"
},
{
"Text": "Banjul Beach",
"Url": "/1x6-enakgm/holidays-banjul-beach",
"Title": "Banjul Beach Holidays"
},
{
"Text": "Bijilo",
"Url": "/1x6-enbmy6/holidays-bijilo",
"Title": "Bijilo Holidays"
},
{
"Text": "Brufut Heights",
"Url": "/1x6-encok8/holidays-brufut-heights",
"Title": "Brufut Heights Holidays"
},
{
"Text": "Kololi",
"Url": "/1x6-enpnle/holidays-kololi",
"Title": "Kololi Holidays"
},
{
"Text": "Kotu",
"Url": "/1x6-enq067/holidays-kotu",
"Title": "Kotu Holidays"
}
]},
"Title": "Cities",
"Type": "PDP"
}
],
"Id": "118431",
"Template": {
"PageTemplate": {
"Code": "2B2",
"text": "041 - TEMP2 - COP_CONCOU_{LAST MINUTE}"
},
"Category": {
"Code": "1X7",
"Type": "Product",
"text": "Last minute holidays"
},
"GeoObject": {
"Code": "EN6ULY",
"text": "Gambia, The"
},
"GeoObjectType": {
"Code": "1A",
"text": "Political"
},
"GeoObjectSubType": {
"Code": "10TR",
"text": "Country"
}
},
"Type": "Content",
"Url": "/1x7-en6uly/last-minute-holidays-gambia",
"_id": {"$oid": "528492d4c90fa9fcd0436929"}
}
I want to sort this by Style in Links.Link 'BrowseForMore'. Any idea how to do it? I thought I could add dummy array with push which could then sort it the way I want. Any help appreciated
You appear to want to update the array and keep the sort order with your Links.Link.Style value at the front of the list. In which case use the $sort modifier with update.
db.collection.update(
{ _id: id },
{ $push: { "Links.Link: {$each: [doc], $sort { Style: -1 }}} }
)
The $each operator is required even if there is only one document, but can take many.
if you are trying to use $addToSet to maintain unique documents the official MongoDB line is that sets are considered to be unordered and hence the modifiers are not available here.

Use a for-in loop to get data from a JSON object which is not an array

I'm trying to loop through the results of a JSON response and get the title of each article, however my hosting company mentioned the returned object is not an array, so I can't loop through the articles.
Currently it gives me an undefined on the length of the amount of articles.
How can I loop through the articles and get their titles?
I tried everything below, and finally read somewhere I could use a for-in loop.
So I was checking out this example here: http://www.w3schools.com/js/tryit.asp?filename=tryjs_object_for_in
However, I have no idea how to apply this loop on my data to get just the articles and then loop through these and get their properties.
JSON RESPONSE
{
"blog": {
"id": "1464",
"comments": true,
"url": "blogs\/magazine",
"rss": "blogs\/magazine.rss",
"title": "Taj Magazine",
"articles": {
"3748": {
"id": 3748,
"image": 7442452,
"url": "blogs\/magazine\/foodies-walhalla-2",
"title": "Foodies Walhalla 2",
"author": "",
"author_url": false,
"summary": "dit is de samenvatting tekst",
"content": "dit is het hele artikel",
"date": "2013-11-13 13:54:00",
"comments": [],
"comments_count": 0,
"tags": {
"foodies-walhalla": {
"id": "9794",
"url": "blogs\/magazine\/tagged\/foodies-walhalla",
"title": "Foodies Walhalla",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3747": {
"id": 3747,
"image": 7442441,
"url": "blogs\/magazine\/foodies-walhalla-1",
"title": "Foodies Walhalla 1",
"author": "",
"author_url": false,
"summary": "f df gdsfg",
"content": "dsfgsdfgdf sdfg",
"date": "2013-11-13 11:22:00",
"comments": [],
"comments_count": 0,
"tags": {
"foodies-walhalla": {
"id": "9794",
"url": "blogs\/magazine\/tagged\/foodies-walhalla",
"title": "Foodies Walhalla",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3744": {
"id": 3744,
"image": 7442425,
"url": "blogs\/magazine\/beauty-artikel-2",
"title": "Beauty artikel 2",
"author": "",
"author_url": false,
"summary": "beauty article 2",
"content": "dfg sfg sdfg sdfgd gdsf df gsdf gdsf g",
"date": "2013-11-13 11:21:00",
"comments": [],
"comments_count": 0,
"tags": {
"beauty": {
"id": "9792",
"url": "blogs\/magazine\/tagged\/beauty",
"title": "beauty",
"count": "2"
},
"healthy": {
"id": "9745",
"url": "blogs\/magazine\/tagged\/healthy",
"title": "healthy",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3745": {
"id": 3745,
"image": 7442417,
"url": "blogs\/magazine\/love-life-1",
"title": "Love & Life 1",
"author": "",
"author_url": false,
"summary": "dfgdsfgd",
"content": "f gdf gdfgdfg dfgdsfgdsfgdsfg",
"date": "2013-11-13 11:21:00",
"comments": [],
"comments_count": 0,
"tags": {
"love-life": {
"id": "9793",
"url": "blogs\/magazine\/tagged\/love-life",
"title": "love & life",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
},
"3746": {
"id": 3746,
"image": 7442388,
"url": "blogs\/magazine\/love-life-2",
"title": "Love & Life 2",
"author": "",
"author_url": false,
"summary": "dfkjghksdjfh gdskfjdj sdlkjfhdjfghdjklfsdfkjhg df gd ghdkjsfhgkjsd fg lkjdshklgdfh kjds glkjsdh kljdsfh",
"content": "dfkjghksdjfh gdskfjdj sdlkjfhdjfghdjklfsdfkjhg df gd ghdkjsfhgkjsd fg lkjdshklgdfh kjds glkjsdh kljdsfh",
"date": "2013-11-13 11:21:00",
"comments": [],
"comments_count": 0,
"tags": {
"love-life": {
"id": "9793",
"url": "blogs\/magazine\/tagged\/love-life",
"title": "love & life",
"count": "2"
},
"magazine": {
"id": "9744",
"url": "blogs\/magazine\/tagged\/magazine",
"title": "magazine",
"count": "6"
}
}
}
}
},
"request": {
"url": "http:\/\/taj-ringen.webshopapp.com\/blogs\/magazine\/?format=json",
"method": "get",
"ssl": false,
"get": {
"format": "json"
},
"post": [],
"device": {
"platform": "windows",
"type": "webkit",
"mobile": false
}
},
"template": "pages\/blog.rain",
"renderer": "json"
}
JAVASCRIPT
<div id="loadstatus"></div>
<script type="text/javascript" language="javascript">
var newresult = '';
$.ajax({
type: "GET",
url: "http://taj-ringen.webshopapp.com/blogs/magazine/?format=json",
data: "",
dataType: "json",
success: function (mydata) {
console.log('load successful');
console.log('mydata.blog.articles.length: ' + mydata.blog.articles.length); //'undefined' error
for (var i = 0; i < mydata.blog.articles.length; i++) {
newresult += mydata.blog.articles[i].title;
}
}
});
</script>
I also had a look at this post: Convert Object to JSON string
tried the jQuery.parseJSON function
console.log(mydata);
var tmp = jQuery.parseJSON(mydata);
console.log(tmp);
console.log('tmp.blog.articles.length: ' + tmp.blog.articles.length);
But there I get an error Uncaught SyntaxError: Unexpected token o on line jquery-1.10.2.min.js:4
tried the $.map function
var array = $.map(mydata, function (e) {
return [$.map(e, function (v) {
return v;
})];
});
console.log(array);
console.log('tmp.blog.articles.length: ' + array.blog.articles.length);
Here I get Uncaught TypeError: Cannot use 'in' operator to search for '14' in pages/blog.rain on line jquery-1.10.2.min.js:4
What I'm trying to to is convert the object that is returned by the site and be able to loop through it.
Iterate through the article object, pulling out the keys associated with each article using the method described in the below post:
How to list the properties of a JavaScript object
You could also use the following loop:
for(var article in blog.articles) {
console.log(blog.articles[article].title);
}

what is wrong with this json array code facebook form

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/

Resources