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

The upper case JSON names #502

Closed
dinya007 opened this issue Feb 4, 2016 · 5 comments
Closed

The upper case JSON names #502

dinya007 opened this issue Feb 4, 2016 · 5 comments

Comments

@dinya007
Copy link

dinya007 commented Feb 4, 2016

There is a bug with JSON filed name converting.

If JSON filed name consist of upper case characters then result Java field name also consist of upper uase characters.

I'll create a pull request which fixes this bug.

Thank you.

@dinya007 dinya007 changed the title Upper case son names The upper case JSON names Feb 4, 2016
@dinya007
Copy link
Author

I don't have enough permissions for creating new branch

@joelittlejohn
Copy link
Owner

Hi. The way to do this with GitHub is to fork this project, create a branch on your fork, add commits there then submit a pull request.

If you Google for 'how to pull request' I think GitHub have a guide. Hope this helps.

@thachhoang
Copy link
Collaborator

Duplicated and fixed by #563.

@thachhoang thachhoang added this to the 0.4.23 milestone Aug 20, 2016
@joelittlejohn joelittlejohn removed this from the 0.4.23 milestone Sep 22, 2018
@safar
Copy link

safar commented Oct 26, 2018

This issue is still present:

  • For field named FOO, class name will be FOO instead of Foo.
  • For field named FOO_BAR class name will be FOOBAR instead of FooBar.

Steps to reproduce:
With default set of property word delimiters, for input:

{
  "type":"object",
  "properties": {
    "FOO_BAR": {
      "type": "string"
    },
    "FOZ": {
      "type": "integer"
    },
    "baz": {
      "type": "boolean"
    }
  }
}

http://www.jsonschema2pojo.org/ generates:

-----------------------------------com.example.Baz.java-----------------------------------

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class Baz {

@SerializedName("type")
@Expose
private String type;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

}
-----------------------------------com.example.Example.java-----------------------------------

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class Example {

@SerializedName("type")
@Expose
private String type;
@SerializedName("properties")
@Expose
private Properties properties;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public Properties getProperties() {
return properties;
}

public void setProperties(Properties properties) {
this.properties = properties;
}

}
-----------------------------------com.example.FOOBAR.java-----------------------------------

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class FOOBAR {

@SerializedName("type")
@Expose
private String type;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

}
-----------------------------------com.example.FOZ.java-----------------------------------

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class FOZ {

@SerializedName("type")
@Expose
private String type;

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

}
-----------------------------------com.example.Properties.java-----------------------------------

package com.example;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

public class Properties {

@SerializedName("FOO_BAR")
@Expose
private FOOBAR fOOBAR;
@SerializedName("FOZ")
@Expose
private FOZ fOZ;
@SerializedName("baz")
@Expose
private Baz baz;

public FOOBAR getFOOBAR() {
return fOOBAR;
}

public void setFOOBAR(FOOBAR fOOBAR) {
this.fOOBAR = fOOBAR;
}

public FOZ getFOZ() {
return fOZ;
}

public void setFOZ(FOZ fOZ) {
this.fOZ = fOZ;
}

public Baz getBaz() {
return baz;
}

public void setBaz(Baz baz) {
this.baz = baz;
}

}

@joelittlejohn
Copy link
Owner

@safar What version are you using?

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

No branches or pull requests

4 participants