Skip to content

JSONWriter breaks on non-public fields #1

@bsouther

Description

@bsouther

Hi Frank
I just noticed that JSONWriter has been filling up my logs with IllegalAccessExceptions. It looks like this happens because, after serializing all of the properties, it tries to serialize the fields but without checking to see if they have public access.

Here is a small test case:

package com;
import org.stringtree.json.*;

public class Bean{
    private String name = "myName";

    public String getName(){ return this.name; }
    public void setName(String name){ this.name = name; }

    public static void main(String ... args)throws Exception{
        String json = new JSONWriter().write(new Bean());
        System.out.println(json);
    }
}

Have you considered adding checks to prevent it from attempting to access non-public fields?

-Ben

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions