Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not serializing arrays of string #6

Closed
GoogleCodeExporter opened this issue Mar 30, 2015 · 2 comments
Closed

Not serializing arrays of string #6

GoogleCodeExporter opened this issue Mar 30, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

Try to serialize and array of String

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

["hello", "world"]
[{},{}]

What version of the product are you using? On what operating system?

Current.  Ubuntu ;)

Please provide any additional information below.

it isn't serializing my array list of strings as it once was, I just get a
list of empty dicts of the same size.

For example the output of :

import com.google.gson.Gson;
import java.util.List;
import java.util.ArrayList;

public class GsonExample {

  public static void main(String args[]) {
    List<String> vals = new ArrayList<String>();
    vals.add("Hello");
    vals.add("World");
    Gson gson = new Gson();
    System.out.println(gson.toJson(vals));
    System.out.println(gson.toJson(vals, List.class));
  }
}

Is :

[{},{}]
[{},{}]

At line 127 of JsonSerializationVisitor the fieldValue of my object is
"ade" for instance and the fieldType is "class java.lang.Object"

At line 131, the childVisitor.getJsonElement() line always returns an empty
dict {}

Regards,

Cameron

Original issue reported on code.google.com by camerong...@gmail.com on 7 May 2008 at 6:21

@GoogleCodeExporter
Copy link
Author

added a test, and reproduced the problem. Thanks for the detailed bug report. 

Original comment by inder123 on 8 May 2008 at 3:52

  • Changed state: Accepted
  • Added labels: ****
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Fixed in r36. See
http://groups.google.com/group/google-gson-codereviews/browse_thread/thread/f6a1
92c317003180

Added new serialization and deserialization tests for array and collection of 
Strings. 

Original comment by inder123 on 8 May 2008 at 4:10

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant