Micronaut CompileStatic JSON object -Static type checking- No such property: bookid for class:...
In my Micronaut Controller I have below code to parse the JSON object. when I use @CompileStatic
annotation it throwing this below error.
@Post("/save")
def save(@Body Object JSON) {
String bookid=JSON?.bookid
String name=JSON?.name
def b =bookService.save(bookid,name)
return HttpResponse.created(b)
}
Error
BookController.groovy: 58: [Static type checking] - No such property: bookid for class: java.lang.Object
Is there way to fix this error message with compilestatic annotation?
Thanks
SR
groovy micronaut
add a comment |
In my Micronaut Controller I have below code to parse the JSON object. when I use @CompileStatic
annotation it throwing this below error.
@Post("/save")
def save(@Body Object JSON) {
String bookid=JSON?.bookid
String name=JSON?.name
def b =bookService.save(bookid,name)
return HttpResponse.created(b)
}
Error
BookController.groovy: 58: [Static type checking] - No such property: bookid for class: java.lang.Object
Is there way to fix this error message with compilestatic annotation?
Thanks
SR
groovy micronaut
1
I'm not a micronaut guy, but in Groovy if you use CompileStatic then you should mostly try to avoid Object, since it won't have compile-time access to anything you want in the Body there. You'll probably want to create a type that hasbookid
andname
fields, and bind to it using@Body
. Here's some docs on binding: docs.micronaut.io/snapshot/guide/index.html#binding
– billjamesdev
Jan 2 at 1:42
@billjamesdev, Thanks for the Point Jeff Brown example helped me. here is the link stackoverflow.com/questions/54000199/…
– sfgroups
Jan 3 at 2:09
Curses, that @jeff-scott-brown guy sure is smart :)
– billjamesdev
Jan 3 at 3:29
add a comment |
In my Micronaut Controller I have below code to parse the JSON object. when I use @CompileStatic
annotation it throwing this below error.
@Post("/save")
def save(@Body Object JSON) {
String bookid=JSON?.bookid
String name=JSON?.name
def b =bookService.save(bookid,name)
return HttpResponse.created(b)
}
Error
BookController.groovy: 58: [Static type checking] - No such property: bookid for class: java.lang.Object
Is there way to fix this error message with compilestatic annotation?
Thanks
SR
groovy micronaut
In my Micronaut Controller I have below code to parse the JSON object. when I use @CompileStatic
annotation it throwing this below error.
@Post("/save")
def save(@Body Object JSON) {
String bookid=JSON?.bookid
String name=JSON?.name
def b =bookService.save(bookid,name)
return HttpResponse.created(b)
}
Error
BookController.groovy: 58: [Static type checking] - No such property: bookid for class: java.lang.Object
Is there way to fix this error message with compilestatic annotation?
Thanks
SR
groovy micronaut
groovy micronaut
edited Jan 2 at 8:57
Szymon Stepniak
17.8k83364
17.8k83364
asked Jan 2 at 0:57
sfgroupssfgroups
5,89994388
5,89994388
1
I'm not a micronaut guy, but in Groovy if you use CompileStatic then you should mostly try to avoid Object, since it won't have compile-time access to anything you want in the Body there. You'll probably want to create a type that hasbookid
andname
fields, and bind to it using@Body
. Here's some docs on binding: docs.micronaut.io/snapshot/guide/index.html#binding
– billjamesdev
Jan 2 at 1:42
@billjamesdev, Thanks for the Point Jeff Brown example helped me. here is the link stackoverflow.com/questions/54000199/…
– sfgroups
Jan 3 at 2:09
Curses, that @jeff-scott-brown guy sure is smart :)
– billjamesdev
Jan 3 at 3:29
add a comment |
1
I'm not a micronaut guy, but in Groovy if you use CompileStatic then you should mostly try to avoid Object, since it won't have compile-time access to anything you want in the Body there. You'll probably want to create a type that hasbookid
andname
fields, and bind to it using@Body
. Here's some docs on binding: docs.micronaut.io/snapshot/guide/index.html#binding
– billjamesdev
Jan 2 at 1:42
@billjamesdev, Thanks for the Point Jeff Brown example helped me. here is the link stackoverflow.com/questions/54000199/…
– sfgroups
Jan 3 at 2:09
Curses, that @jeff-scott-brown guy sure is smart :)
– billjamesdev
Jan 3 at 3:29
1
1
I'm not a micronaut guy, but in Groovy if you use CompileStatic then you should mostly try to avoid Object, since it won't have compile-time access to anything you want in the Body there. You'll probably want to create a type that has
bookid
and name
fields, and bind to it using @Body
. Here's some docs on binding: docs.micronaut.io/snapshot/guide/index.html#binding– billjamesdev
Jan 2 at 1:42
I'm not a micronaut guy, but in Groovy if you use CompileStatic then you should mostly try to avoid Object, since it won't have compile-time access to anything you want in the Body there. You'll probably want to create a type that has
bookid
and name
fields, and bind to it using @Body
. Here's some docs on binding: docs.micronaut.io/snapshot/guide/index.html#binding– billjamesdev
Jan 2 at 1:42
@billjamesdev, Thanks for the Point Jeff Brown example helped me. here is the link stackoverflow.com/questions/54000199/…
– sfgroups
Jan 3 at 2:09
@billjamesdev, Thanks for the Point Jeff Brown example helped me. here is the link stackoverflow.com/questions/54000199/…
– sfgroups
Jan 3 at 2:09
Curses, that @jeff-scott-brown guy sure is smart :)
– billjamesdev
Jan 3 at 3:29
Curses, that @jeff-scott-brown guy sure is smart :)
– billjamesdev
Jan 3 at 3:29
add a comment |
2 Answers
2
active
oldest
votes
With Help of Jeff Brown I have changed. my save method like this.
@Post('/')
Book save(Book b) {
bookService.save b
}
Micronaut JSON post strip the Qutoes
add a comment |
You can also work with your method instead of changing it for parsing.I encountered the same problem and the method that worked for me is using String instead of object. Just use JSON String along with @BODY and then parse it using ObjectMapper().
here is the answer i posted at some other question, hope it will help you out.
https://stackoverflow.com/a/54905403/7803105
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000149%2fmicronaut-compilestatic-json-object-static-type-checking-no-such-property-boo%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
With Help of Jeff Brown I have changed. my save method like this.
@Post('/')
Book save(Book b) {
bookService.save b
}
Micronaut JSON post strip the Qutoes
add a comment |
With Help of Jeff Brown I have changed. my save method like this.
@Post('/')
Book save(Book b) {
bookService.save b
}
Micronaut JSON post strip the Qutoes
add a comment |
With Help of Jeff Brown I have changed. my save method like this.
@Post('/')
Book save(Book b) {
bookService.save b
}
Micronaut JSON post strip the Qutoes
With Help of Jeff Brown I have changed. my save method like this.
@Post('/')
Book save(Book b) {
bookService.save b
}
Micronaut JSON post strip the Qutoes
answered Jan 3 at 2:15
sfgroupssfgroups
5,89994388
5,89994388
add a comment |
add a comment |
You can also work with your method instead of changing it for parsing.I encountered the same problem and the method that worked for me is using String instead of object. Just use JSON String along with @BODY and then parse it using ObjectMapper().
here is the answer i posted at some other question, hope it will help you out.
https://stackoverflow.com/a/54905403/7803105
add a comment |
You can also work with your method instead of changing it for parsing.I encountered the same problem and the method that worked for me is using String instead of object. Just use JSON String along with @BODY and then parse it using ObjectMapper().
here is the answer i posted at some other question, hope it will help you out.
https://stackoverflow.com/a/54905403/7803105
add a comment |
You can also work with your method instead of changing it for parsing.I encountered the same problem and the method that worked for me is using String instead of object. Just use JSON String along with @BODY and then parse it using ObjectMapper().
here is the answer i posted at some other question, hope it will help you out.
https://stackoverflow.com/a/54905403/7803105
You can also work with your method instead of changing it for parsing.I encountered the same problem and the method that worked for me is using String instead of object. Just use JSON String along with @BODY and then parse it using ObjectMapper().
here is the answer i posted at some other question, hope it will help you out.
https://stackoverflow.com/a/54905403/7803105
answered Feb 27 at 12:28
Zaryab balochZaryab baloch
175
175
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000149%2fmicronaut-compilestatic-json-object-static-type-checking-no-such-property-boo%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I'm not a micronaut guy, but in Groovy if you use CompileStatic then you should mostly try to avoid Object, since it won't have compile-time access to anything you want in the Body there. You'll probably want to create a type that has
bookid
andname
fields, and bind to it using@Body
. Here's some docs on binding: docs.micronaut.io/snapshot/guide/index.html#binding– billjamesdev
Jan 2 at 1:42
@billjamesdev, Thanks for the Point Jeff Brown example helped me. here is the link stackoverflow.com/questions/54000199/…
– sfgroups
Jan 3 at 2:09
Curses, that @jeff-scott-brown guy sure is smart :)
– billjamesdev
Jan 3 at 3:29