Click here to Skip to main content
14,882,025 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a class AgeCriteria in that class i have 2 more classes like MinmumAge and MaximumAge.

how can i get below Json Format using Jquery.

"AgeCriteria": {
         "MinimumAge": {
            "Age": "50",
            "AgeUnitID": "2",
            "AgeUnit": "Year"
         "MaximumAgemumAge": {
            "Age": "",
            "AgeUnitID": "",
            "AgeUnit": ""

What I have tried:

var _AgeCriteria=[];

 var MinAgeCriteria = { AgeType: "Min", Age: minAge, AgeUnitID: "1", AgeUnit: minUnit };
            var MaxAgeCriteria = { AgeType: "Max", Age: maxAge, AgeUnitID: "1", AgeUnit: maxUnit };

above array give this result

Updated 17-May-17 4:53am

1 solution

Something like

var criteria = {AgeCriteria: {MinimumAge : {Age:50, AgeUnitID:2, AgeUnit:"Year"}, MaximumAgemumAge: {Age:25, AgeUnitID:1, AgeUnit:"Year"}}};

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900