My favorites | Sign in
Project Home
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 52: CJSONSerializer serializeArray doesn't correctly handle arrays with the same instances in certain places.
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  May 2009


 
Reported by magnus...@gmail.com, Mar 19, 2009
What steps will reproduce the problem?

Create an array that contains the same instance somewhere in the middle and
as the final element, e.g.,

    NSString* a = @"a";
    NSArray* array = [NSArray arrayWithObjects:a, @"b", a, nil];

What is the expected output? What do you see instead?

If that array is serialized, it should look like this:

    ["a","b","a"]

but it looks like this:

    ["a""b","a"]

The check to see if the last element of the array is serialized, and this,
if a "," string should be appended or not, is not reliable. "theValue" can
be the same as the last object, even though it isn't the last element in
the array.

This bug is present in revision 162 of the file.
May 16, 2009
#1 jpedroso@gmail.com
Patch attached with test to reproduce the issue and the fix. 
Replaced lastObject test with a counter to do the conditional test against the number of elements in the array 
instead.
CJSONSerializer_Issue52.patch
1.3 KB   View   Download
May 16, 2009
Project Member #2 jwight
Thanks for the patch & unit test. Looks good to me.
Status: Fixed

Powered by Google Project Hosting