avvllvva Posted October 31, 2011 Share Posted October 31, 2011 Following is my current json obj string [ {"productId":"101","price":99}, {"productId":"201","price":88}, {"productId":"301","price":77}, {"productId":"101","count":3}, {"productId":"201","count":5}], {"productId":"301","count":2}], {"productId":"101","month":12}, {"productId":"201","month":10}], {"productId":"301","month":09} ] i want to convert it into following format ie; grouping by product id along with their parameters together [ {products:'101',parameters[99,3,12]}, {products:'201',parameters[88,5,10]}, {products:'301',parameters[77,2,09]} ] -thanks Quote Link to comment Share on other sites More sharing options...
trq Posted October 31, 2011 Share Posted October 31, 2011 Have you tired anything or your just looking for someone to do it for you? Quote Link to comment Share on other sites More sharing options...
haku Posted October 31, 2011 Share Posted October 31, 2011 Solution: Instead of using this: [ {"productId":"101","price":99}, {"productId":"201","price":88}, {"productId":"301","price":77}, {"productId":"101","count":3}, {"productId":"201","count":5}], {"productId":"301","count":2}], {"productId":"101","month":12}, {"productId":"201","month":10}], {"productId":"301","month":09} ] Use this: [ {products:'101',parameters[99,3,12]}, {products:'201',parameters[88,5,10]}, {products:'301',parameters[77,2,09]} ] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.