rfostii / wadofstuff

Automatically exported from code.google.com/p/wadofstuff
0 stars 0 forks source link

json with jqgrid #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am currently unable to get this working with jqgrid.
I am currently using the serializer attached.

I'm not too familiar with json data and would be grateful if you could help
me out. I am very interested in excluding fields. 

Another great feature would be to just include some fields instead of
needing to exclude 50 fields I could just use 5.

Great project. TIA

Here is the serialized data with the attached serializer:

{"total":0, "records":2, "rows":[{"pk": 1, "model": "listing.listing",
"fields": {"lockbox_location": "In the middle of the frozen pond.",
"add3_name": null, "bedroom4_level": null, "escrow_pref": "",
"tenant_name": "", "basement": [6, 7], "lot_amenities": [4, 5, 6, 7, 18],
"lot_size": "4", "beds_total": null, "property_type": "manufactured",
"kitchen_l": 10, "commission_percent": 3.0, "acres": null, "home_style":
"colonial", "kitchen_w": 40, "living_w": 20, "commission_dollar": null,
"zoning": "RR5", "middle_school": "Lowell", "bare_land": false,
"sqft_lower": 900, "sqft_total": 2700, "sqft_upper": 900, "living_l": 30,
"tax_id": 88888888, "garage2": null, "sqft_main": 900, "agent_comments":
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sed lacus.
Mauris vel augue ac sem condimentum ornare. Curabitur enim. Cras a metus
nec purus rhoncus tempor. Proin porttitor felis. Quisque augue mauris,
lobortis in, condimentum nec, eleifend sit amet, orci. Vivamus placerat
eros in dui. Ut in odio vel ipsum elementum aliquam. Etiam cras amet. ",
"family_level": "M", "taxes": 9999, "tour_link": "", "garage": "attached",
"list_type": "er", "living_level": "U", "short_sale": false, "add3_level":
null, "occupied_by": "owner", "terms": [3, 7, 8], "lockbox": true,
"forclosure": false, "list_expiration_date": "2009-12-02", "bedroom2_l":
10, "age_identity": "original", "state": "OR", "bedroom2_w": 13,
"owner_phone": "541-999-9999", "fireplace_description": [3, 4, 5],
"high_school": "Lowell", "add1_l": null, "kitchen_level": "M",
"owner_name": "Ted Jones", "bedroom4_w": null, "bedroom2_level": "L",
"dining_level": "M", "add2_name": null, "dining_l": 10, "add3_w": null,
"showing_options": [3, 5, 11], "hours": "4am-4:30am", "dining_w": 23,
"address": "123 Park Ave", "directions": "Through the candy cane forest
down the land of swirly twirly gumdrops and through the lincoln tunnel.
DON'T EAT THE GUM", "bedroom3_l": 10, "add1_w": null, "bedroom4_l": null,
"water": [1, 3], "tax_deferral": false, "baths_lower": 1.1000000000000001,
"price_per_sqft": 333, "add3_l": null, "county": "somecounty", "hoa_dues":
null, "floors": 3, "electrical_service": false, "rented": false, "city":
"Beaverton", "baths_main": 1.1000000000000001, "zip": 97123, "list_date":
"2008-12-02", "mfg_home_style": null, "terms_agreement": false,
"fsmls_tour": false, "elementary_school": "Lowell", "tenant_phone": "",
"kitchen": [1, 6, 7, 11, 12], "bedroom3_w": 15, "lot_description": [2, 5,
6], "add2_w": null, "listing_agent": 1, "water_name": "Fall Creek",
"bedroom5_w": null, "second_residence": false, "bedroom5_l": null,
"add1_name": null, "add2_l": null, "lot_dimension2": 100, "hoa_freq": null,
"lot_dimension1": 100, "master_w": 20, "master_level": "U", "beds_lower":
2, "bedroom5_level": null, "master_l": 10, "baths_total":
3.2999999999999998, "add2_level": null, "lot_proximity": [1, 2, 4, 5, 6,
12], "exterior_siding": [6], "year_green_certified": null, "exterior": [3,
7, 8, 9, 11], "bedroom3_level": "L", "family_w": 20, "built": 1940,
"co_listing_agent": null, "hotwater": [3, 4], "garage2_spaces": null,
"negotiate_with_seller": false, "heating_delivery": [3, 4], "interior": [2,
3, 6, 7, 8], "family_l": 43, "status": "ACT", "heating_fuel": [5, 7],
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Cras aliquet ante id velit. Ut massa elit, cursus vitae, consequat in,
pretium ut, orci. Nullam eget libero ac mi adipiscing accumsan. Aliquam et
urna. Maecenas urna nunc, vulputate id, adipiscing quis, ultrices sit amet,
dolor. Nunc sit amet dui vitae enim pharetra ullamcorper. Nulla pretium.
Quisque justo velit, porttitor non, laoreet et, imperdiet vel, velit. Sed
placerat libero placerat ipsum. Vivamus scelerisque. Vestibulum cras amet.
", "handicap": false, "price": 900000, "beds_upper": 1, "beds_main": 2,
"MLS": 4352524, "garage_spaces": 3, "waterfront": null, "add1_level": null,
"baths_upper": 1.1000000000000001, "green_certified": false, "sewer": [4,
6]}}, {"pk": 4, "model": "listing.listing", "fields": {"lockbox_location":
"", "add3_name": null, "bedroom4_level": null, "escrow_pref": "First
American Title Company", "tenant_name": "", "basement": [],
"lot_amenities": [], "lot_size": "7", "beds_total": null, "property_type":
null, "kitchen_l": null, "commission_percent": 2.5, "acres": 5.0,
"home_style": "aframe", "kitchen_w": null, "living_w": null,
"commission_dollar": null, "zoning": "RR5", "middle_school": "Sheldon",
"bare_land": false, "sqft_lower": null, "sqft_total": 1800, "sqft_upper":
900, "living_l": null, "tax_id": 98721000, "garage2": null, "sqft_main":
900, "agent_comments": "", "family_level": "U", "taxes": 19, "tour_link":
"", "garage": "detached", "list_type": "er", "living_level": "U",
"short_sale": false, "add3_level": null, "occupied_by": "owner", "terms":
[6, 9], "lockbox": false, "forclosure": false, "list_expiration_date":
"2009-12-09", "bedroom2_l": null, "age_identity": "remodel", "state": "OR",
"bedroom2_w": null, "owner_phone": "", "fireplace_description": [],
"high_school": "Lowell", "add1_l": null, "kitchen_level": "U",
"owner_name": "", "bedroom4_w": null, "bedroom2_level": "M",
"dining_level": "U", "add2_name": null, "dining_l": null, "add3_w": null,
"showing_options": [], "hours": "", "dining_w": null, "address": "2233
Cottage way", "directions": "Right next to joey's pizza!", "bedroom3_l":
null, "add1_w": null, "bedroom4_l": null, "water": [], "tax_deferral":
false, "baths_lower": 2.1000000000000001, "price_per_sqft": 82, "add3_l":
null, "county": "Lane", "hoa_dues": null, "floors": 2,
"electrical_service": false, "rented": false, "city": "Cottage Grove",
"baths_main": 1.1000000000000001, "zip": 97472, "list_date": "2008-12-09",
"mfg_home_style": null, "terms_agreement": false, "fsmls_tour": false,
"elementary_school": "Pleasant Hill", "tenant_phone": "", "kitchen": [],
"bedroom3_w": null, "lot_description": [], "add2_w": null, "listing_agent":
1, "water_name": "", "bedroom5_w": null, "second_residence": false,
"bedroom5_l": null, "add1_name": null, "add2_l": null, "lot_dimension2":
null, "hoa_freq": null, "lot_dimension1": null, "master_w": null,
"master_level": "M", "beds_lower": null, "bedroom5_level": null,
"master_l": null, "baths_total": 5.4000000000000004, "add2_level": null,
"lot_proximity": [], "exterior_siding": [], "year_green_certified": null,
"exterior": [], "bedroom3_level": null, "family_w": null, "built": 1978,
"co_listing_agent": null, "hotwater": [], "garage2_spaces": null,
"negotiate_with_seller": false, "heating_delivery": [], "interior": [],
"family_l": null, "status": "ACT", "heating_fuel": [], "description": "This
is a two story A-Frame with the bedrooms on the main floor and all of the
other rooms up stairs.", "handicap": false, "price": 149000, "beds_upper":
null, "beds_main": null, "MLS": 7777777, "garage_spaces": 8, "waterfront":
null, "add1_level": null, "baths_upper": 2.2000000000000002,
"green_certified": false, "sewer": []}}] }

And here is the data serialized with wadofstuff:
{"total":0, "records":2, "rows":[{"lockbox_location": "In the middle of the
frozen pond.", "add3_name": null, "co_listing_agent_id": null,
"bedroom4_level": null, "escrow_pref": "", "tenant_name": "", "lot_size":
"4", "beds_total": null, "property_type": "manufactured", "kitchen_l": 10,
"commission_percent": 3.0, "acres": null, "home_style": "colonial",
"kitchen_w": 40, "living_w": 20, "commission_dollar": null, "zoning":
"RR5", "middle_school": "Lowell", "bare_land": false, "sqft_lower": 900,
"sqft_total": 2700, "sqft_upper": 900, "living_l": 30, "tax_id": 88888888,
"garage2": null, "sqft_main": 900, "agent_comments": "Lorem ipsum dolor sit
amet, consectetur adipiscing elit. Mauris sed lacus. Mauris vel augue ac
sem condimentum ornare. Curabitur enim. Cras a metus nec purus rhoncus
tempor. Proin porttitor felis. Quisque augue mauris, lobortis in,
condimentum nec, eleifend sit amet, orci. Vivamus placerat eros in dui. Ut
in odio vel ipsum elementum aliquam. Etiam cras amet. ", "family_level":
"M", "taxes": 9999, "tour_link": "", "garage": "attached", "list_type":
"er", "living_level": "U", "short_sale": false, "listing_agent_id": 1,
"add3_level": null, "occupied_by": "owner", "lockbox": true, "forclosure":
false, "list_expiration_date": "2009-12-02", "bedroom2_l": 10,
"age_identity": "original", "state": "OR", "bedroom2_w": 13, "owner_phone":
"541-999-9999", "high_school": "Lowell", "add1_l": null, "kitchen_level":
"M", "owner_name": "Ted Jones", "bedroom4_w": null, "bedroom2_level": "L",
"dining_level": "M", "add2_name": null, "dining_l": 10, "add3_w": null,
"hours": "4am-4:30am", "dining_w": 23, "address": "123 Park Ave",
"directions": "Through the candy cane forest down the land of swirly twirly
gumdrops and through the lincoln tunnel. DON'T EAT THE GUM", "bedroom3_l":
10, "add1_w": null, "bedroom4_l": null, "tax_deferral": false,
"baths_lower": 1.1000000000000001, "price_per_sqft": 333, "add3_l": null,
"county": "somecounty", "hoa_dues": null, "floors": 3,
"electrical_service": false, "rented": false, "city": "Beaverton",
"baths_main": 1.1000000000000001, "zip": 97123, "list_date": "2008-12-02",
"mfg_home_style": null, "terms_agreement": false, "fsmls_tour": false,
"elementary_school": "Lowell", "tenant_phone": "", "bedroom3_w": 15,
"add2_w": null, "water_name": "Fall Creek", "bedroom5_w": null,
"second_residence": false, "bedroom5_l": null, "add1_name": null, "add2_l":
null, "lot_dimension2": 100, "hoa_freq": null, "lot_dimension1": 100,
"master_w": 20, "master_level": "U", "beds_lower": 2, "bedroom5_level":
null, "master_l": 10, "baths_total": 3.2999999999999998, "add2_level":
null, "year_green_certified": null, "id": 1, "bedroom3_level": "L",
"family_w": 20, "built": 1940, "garage2_spaces": null,
"negotiate_with_seller": false, "family_l": 43, "status": "ACT",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Cras aliquet ante id velit. Ut massa elit, cursus vitae, consequat in,
pretium ut, orci. Nullam eget libero ac mi adipiscing accumsan. Aliquam et
urna. Maecenas urna nunc, vulputate id, adipiscing quis, ultrices sit amet,
dolor. Nunc sit amet dui vitae enim pharetra ullamcorper. Nulla pretium.
Quisque justo velit, porttitor non, laoreet et, imperdiet vel, velit. Sed
placerat libero placerat ipsum. Vivamus scelerisque. Vestibulum cras amet.
", "handicap": false, "price": 900000, "beds_upper": 1, "beds_main": 2,
"MLS": 4352524, "garage_spaces": 3, "waterfront": null, "add1_level": null,
"baths_upper": 1.1000000000000001, "green_certified": false},
{"lockbox_location": "", "add3_name": null, "co_listing_agent_id": null,
"bedroom4_level": null, "escrow_pref": "First American Title Company",
"tenant_name": "", "lot_size": "7", "beds_total": null, "property_type":
null, "kitchen_l": null, "commission_percent": 2.5, "acres": 5.0,
"home_style": "aframe", "kitchen_w": null, "living_w": null,
"commission_dollar": null, "zoning": "RR5", "middle_school": "Sheldon",
"bare_land": false, "sqft_lower": null, "sqft_total": 1800, "sqft_upper":
900, "living_l": null, "tax_id": 98721000, "garage2": null, "sqft_main":
900, "agent_comments": "", "family_level": "U", "taxes": 19, "tour_link":
"", "garage": "detached", "list_type": "er", "living_level": "U",
"short_sale": false, "listing_agent_id": 1, "add3_level": null,
"occupied_by": "owner", "lockbox": false, "forclosure": false,
"list_expiration_date": "2009-12-09", "bedroom2_l": null, "age_identity":
"remodel", "state": "OR", "bedroom2_w": null, "owner_phone": "",
"high_school": "Lowell", "add1_l": null, "kitchen_level": "U",
"owner_name": "", "bedroom4_w": null, "bedroom2_level": "M",
"dining_level": "U", "add2_name": null, "dining_l": null, "add3_w": null,
"hours": "", "dining_w": null, "address": "2233 Cottage way", "directions":
"Right next to joey's pizza!", "bedroom3_l": null, "add1_w": null,
"bedroom4_l": null, "tax_deferral": false, "baths_lower":
2.1000000000000001, "price_per_sqft": 82, "add3_l": null, "county": "Lane",
"hoa_dues": null, "floors": 2, "electrical_service": false, "rented":
false, "city": "Cottage Grove", "baths_main": 1.1000000000000001, "zip":
97472, "list_date": "2008-12-09", "mfg_home_style": null,
"terms_agreement": false, "fsmls_tour": false, "elementary_school":
"Pleasant Hill", "tenant_phone": "", "bedroom3_w": null, "add2_w": null,
"water_name": "", "bedroom5_w": null, "second_residence": false,
"bedroom5_l": null, "add1_name": null, "add2_l": null, "lot_dimension2":
null, "hoa_freq": null, "lot_dimension1": null, "master_w": null,
"master_level": "M", "beds_lower": null, "bedroom5_level": null,
"master_l": null, "baths_total": 5.4000000000000004, "add2_level": null,
"year_green_certified": null, "id": 4, "bedroom3_level": null, "family_w":
null, "built": 1978, "garage2_spaces": null, "negotiate_with_seller":
false, "family_l": null, "status": "ACT", "description": "This is a two
story A-Frame with the bedrooms on the main floor and all of the other
rooms up stairs.", "handicap": false, "price": 149000, "beds_upper": null,
"beds_main": null, "MLS": 7777777, "garage_spaces": 8, "waterfront": null,
"add1_level": null, "baths_upper": 2.2000000000000002, "green_certified":
false}] }

Original issue reported on code.google.com by corn13r...@gmail.com on 1 Mar 2009 at 11:05

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

The standard Django serializer has a 'fields' option that allows you to specify 
only 
the fields you want to serialize.

{{{
from django.core import serializers

serializers.serialize('json', your_queryset, fields=('county', 'address', 
'etc'))
}}}

Start with reading http://docs.djangoproject.com/en/dev/topics/serialization 
then DjangoFullSerializers. If you need to exclude fields you'll need to use my 
serializer.

Original comment by mattimus...@gmail.com on 2 Mar 2009 at 12:16