-
Notifications
You must be signed in to change notification settings - Fork 126
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
Can't use lowerCamelCase attributes for an nested object in JSON. #449
Comments
@devdufutur This works fine for me. Can you provide more details about your build configuration? The pom.xml or build.gradle may help diagnose what is wrong. Thanks. |
Sure !
` I even tried by adding this kind of JSON in a clone of manifold-sample-project, I had the same result :/ |
There appears to be a conflict between |
- json type manifold code gen, maintain a single file field at the top-level and reference that with fully qualified name, avoids naming collision with manifold-props
- handle shadowing where an instance field shadows an inner class of the same name. This is particularly useful in code gen where both a property and an inner type are derived from the same element. Otherwise, use-cases such as: Person.address.builder(), don't work because address resolves as the field and not the inner class. - json type manifold code gen, maintain a single file field at the top-level and reference that with fully qualified name, avoids naming collision with manifold-props
- handle shadowing where an instance field shadows an inner class of the same name. This is particularly useful in code gen where both a property and an inner type are derived from the same element. Otherwise, use-cases such as: Person.address.builder(), don't work because address resolves as the field and not the inner class.
Fix available with release 2023.1.8, IntelliJ plugin update published. Note, IntelliJ plugin update is usually available within 24 hours of publishing. Thanks for filing this issue! |
Sorry, forgot to reply ! It worked great without manifold-props as a fix. Thanks @rsmckinney. |
Describe the bug
The use of lowerCamelCase attribute for a nested object in JSON leads to an error.
To Reproduce
Steps to reproduce the behavior:
1.Create a Person.json with the following content :
{ "name": "John Doe", "age": 39, "address": { "number": 9604, "street": "Donald Court", "city": "Golden Shores", "state": "FL" } }
2.Instanciate Person object like that :
var person = Person.builder() .withName("Someone") .build(); System.out.println(person.write().toJson());
Expected behavior
It should compile, run and print something like :
{ "name": "Someone" }
Screenshots
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
Stack trace
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ testmanifold4 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\Users\Rudy\IdeaProjects\testmanifold4\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /org/example/model/Person.java:[113,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[113,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[116,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[116,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[120,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[120,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[123,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[123,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[127,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[127,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[130,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[130,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[134,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[134,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[137,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[137,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[148,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[148,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[151,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[151,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[154,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[154,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[157,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[157,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[113,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[116,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[120,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[123,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[127,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[130,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[134,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[137,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[148,45] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[151,45] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[154,45] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[157,45] Cannot access write-only property 'address'
[INFO] 36 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.892 s
[INFO] Finished at: 2023-05-08T20:42:17+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project testmanifold4: Compilation failure: Compilation failure:
[ERROR] /org/example/model/Person.java:[113,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[113,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[116,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[116,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[120,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[120,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[123,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[123,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[127,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[127,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[130,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[130,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[134,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[134,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[137,43] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[137,50] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[148,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[148,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[151,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[151,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[154,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[154,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[157,45] non-static variable address cannot be referenced from a static context
[ERROR] /org/example/model/Person.java:[157,52] element value must be a constant expression
[ERROR] /org/example/model/Person.java:[113,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[116,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[120,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[123,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[127,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[130,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[134,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[137,43] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[148,45] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[151,45] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[154,45] Cannot access write-only property 'address'
[ERROR] /org/example/model/Person.java:[157,45] Cannot access write-only property 'address'
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Process finished with exit code 1
The text was updated successfully, but these errors were encountered: