Hi,

 for (var i = 0; i < result.length; i++) {
            print("The " + i + "th result is : "+ stringify(result[i]));
}

will print results as String
eg: out put

The 1 th result is : {"PROD_NAME" : "Sugar", "QUANTITY_SOLD" : "3760",
"TOTAL_AMOUNT" : "34800.0", "PROD_ID" : "55"}

 for (var i = 0; i < result.length; i++) {
            print("The " + i + "th provider is : "+ result[i].PROD_NAME);
}

will Print providers
eg:out put

The 1 th provider is : Sugar

This above code test, It work in M4

Thank you

On Wed, May 2, 2012 at 5:49 PM, Nuwan Bandara <[email protected]> wrote:

> Hi Tharindu,
>
> hmmm will have to debug a little and see. I have done som changes to the
> json parser, so take an update of jaggery stuff and try it out. if fails,
> lets have a look offline.
>
> Regards,
> /Nuwan
>
>
> On Wed, May 2, 2012 at 2:53 PM, Tharindu Mathew <[email protected]> wrote:
>
>> the part that gets printed is cause of the first line...
>>
>> If you notice, the print in the loop causes the error.
>>
>>
>> On Wed, May 2, 2012 at 2:12 PM, Nuwan Bandara <[email protected]> wrote:
>>
>>> so some parts are getting printed while some are not, can you identify
>>> whats the result element that cannot get printed
>>>
>>>
>>> On Wed, May 2, 2012 at 1:57 PM, Tharindu Mathew <[email protected]>wrote:
>>>
>>>>  #11:           print("The " + i + "th result is : " + result[i]);
>>>>
>>>> so the object that causes this is result[i]
>>>>
>>>> On Wed, May 2, 2012 at 1:51 PM, Nuwan Bandara <[email protected]> wrote:
>>>>
>>>>> whats the object at line #11
>>>>>
>>>>>
>>>>> On Wed, May 2, 2012 at 1:47 PM, Tharindu Mathew <[email protected]>wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, May 2, 2012 at 1:33 PM, Nuwan Bandara <[email protected]> wrote:
>>>>>>
>>>>>>> result is an array of json objects ?
>>>>>>
>>>>>> yes
>>>>>>
>>>>>>> Cannot exactly tell the issue from the code you have sent. how did
>>>>>>> you create the array.
>>>>>>
>>>>>> it is a result from a db query.
>>>>>>
>>>>>>> There is a know issue in json stringyfy and parse [1], but am not
>>>>>>> sure if thats the case for your scenario.
>>>>>>>
>>>>>>> [1] https://wso2.org/jira/browse/JAGGERY-205
>>>>>>>
>>>>>> I think it's different. This is a valid json object.
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, May 2, 2012 at 1:10 PM, Tharindu Mathew 
>>>>>>> <[email protected]>wrote:
>>>>>>>
>>>>>>>> Hi Jag devs,
>>>>>>>>
>>>>>>>> Initial investigation reveals that this is something to do with how
>>>>>>>> reflections are handled when using Rhino, probably in toString() for a 
>>>>>>>> json
>>>>>>>> element.
>>>>>>>>
>>>>>>>> Is there something wrong with the code? or is this expected?
>>>>>>>>
>>>>>>>> Code:
>>>>>>>>
>>>>>>>> print (result);
>>>>>>>> for (var i = 0; i < result.length; i++) {
>>>>>>>>             print("The " + i + "th result is : " + result[i]);
>>>>>>>> }
>>>>>>>>
>>>>>>>> Output:
>>>>>>>> [{"PROD_NAME" : "Sugar", "QUANTITY_SOLD" : "3760", "TOTAL_AMOUNT" :
>>>>>>>> "34800.0", "PROD_ID" : "55"}, {"PROD_NAME" : "Milk", "QUANTITY_SOLD" :
>>>>>>>> "563", "TOTAL_AMOUNT" : "24500.0", "PROD_ID" : "124"}, {"PROD_NAME" :
>>>>>>>> "Bread", "QUANTITY_SOLD" : "5604", "TOTAL_AMOUNT" : "124900.0", 
>>>>>>>> "PROD_ID" :
>>>>>>>> "235"}, {"PROD_NAME" : "Butter", "QUANTITY_SOLD" : "320", 
>>>>>>>> "TOTAL_AMOUNT" :
>>>>>>>> "16900.0", "PROD_ID" : "346"}]
>>>>>>>>
>>>>>>>> Cannot find default value for object. at line #11
>>>>>>>>
>>>>>>>> --
>>>>>>>> Regards,
>>>>>>>>
>>>>>>>> Tharindu
>>>>>>>>
>>>>>>>> blog: http://mackiemathew.com/
>>>>>>>> M: +94777759908
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dev mailing list
>>>>>>>> [email protected]
>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> *Thanks & Regards,
>>>>>>>
>>>>>>> Nuwan Bandara
>>>>>>> Associate Technical Lead & Member, MC, Development Technologies
>>>>>>> WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
>>>>>>> blog : http://nuwanbando.com; email: [email protected]; phone: +94 11
>>>>>>> 763 9629
>>>>>>> *
>>>>>>> <http://www.nuwanbando.com/>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>>
>>>>>> Tharindu
>>>>>>
>>>>>> blog: http://mackiemathew.com/
>>>>>> M: +94777759908
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Thanks & Regards,
>>>>>
>>>>> Nuwan Bandara
>>>>> Associate Technical Lead & Member, MC, Development Technologies
>>>>> WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
>>>>> blog : http://nuwanbando.com; email: [email protected]; phone: +94 11
>>>>> 763 9629
>>>>> *
>>>>> <http://www.nuwanbando.com/>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>>
>>>> Tharindu
>>>>
>>>> blog: http://mackiemathew.com/
>>>> M: +94777759908
>>>>
>>>>
>>>
>>>
>>> --
>>> *Thanks & Regards,
>>>
>>> Nuwan Bandara
>>> Associate Technical Lead & Member, MC, Development Technologies
>>> WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
>>> blog : http://nuwanbando.com; email: [email protected]; phone: +94 11 763
>>> 9629
>>> *
>>> <http://www.nuwanbando.com/>
>>>
>>
>>
>>
>> --
>> Regards,
>>
>> Tharindu
>>
>> blog: http://mackiemathew.com/
>> M: +94777759908
>>
>>
>
>
> --
> *Thanks & Regards,
>
> Nuwan Bandara
> Associate Technical Lead & Member, MC, Development Technologies
> WSO2 Inc. - lean . enterprise . middleware |  http://wso2.com
> blog : http://nuwanbando.com; email: [email protected]; phone: +94 11 763
> 9629
> *
> <http://www.nuwanbando.com/>
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
*Madhuka* Udantha
http://madhukaudantha.blogspot.com/
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to