I am facing an issue in converting following html code to json:
<div class="control" >
<label>Caption</label><br>
<select name="" class="dropdowntag">
<option value="Option1">Option1</option>
<option value="Option2">Option2</option>
</select>
</div>
In this resultant JSON, the select tag is missing, following is the result that I get from the transform builder provided in json2html site.
{"tag":"div","class":"control","children":[
{"tag":"label","html":"Caption"},
{"tag":"br","html":""}, [
{"tag":"option","value":"Option1","html":"Option1"},
{"tag":"option","value":"Option2","html":"Option2"}
]
]}
If I remove the outer div I am getting the json properly. Following is the modified html and its json result:
<label>Caption</label><br>
<select name="" class="dropdowntag">
<option value="Option1">Option1</option>
<option value="Option2">Option2</option>
</select>
[
{"tag":"label","html":"Caption"},
{"tag":"br","html":""},
{"tag":"select","class":"dropdowntag","name":"","children":[
{"tag":"option","value":"Option1","html":"Option1"},
{"tag":"option","value":"Option2","html":"Option2"}
]}
]
Not able to figure it out the reason for this issue.
Note: If I change the select tag to some other valid html tag or just give any other name than select it works fine.
Following are the version of jquery and json2html plugin used for this:
- jquery-1.11.1
- jquery-ui-1.11.0
- json2html - current version available to download.
Following is the link to json2html plugin site: json2html The builder tab in this page provides the option to build the transformer based on html.