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

Short example of JSON PUT ACTION #1

Open
zotona opened this issue Dec 3, 2015 · 3 comments
Open

Short example of JSON PUT ACTION #1

zotona opened this issue Dec 3, 2015 · 3 comments

Comments

@zotona
Copy link

zotona commented Dec 3, 2015

Hi! Very interesting project! Could you provide some small example to persist json string to orient?

@eugene-kamenev
Copy link
Owner

@zotona
Ok i will provide two examples:

  1. spring way
@RequestMapping(method = RequestMethod.PUT)
def putPerson(Person p) {
    graphFactory.withTransaction {
           p.save()
    }
}

In the above case you must register jackson object mapper for your object, but i didnt tested how it works with this lib.

  1. groovy way
@RequestMapping(method = RequestMethod.PUT)
def putPerson(String person) {
    def slurper = new  groovy.json.JsonSlurper()
    graphFactory.withTransaction {
           new Person((Map) slurper.parseText(person)).save()
    }
}

@eugene-kamenev
Copy link
Owner

You can give a star if you like this project. Thank you.

@zotona
Copy link
Author

zotona commented Dec 4, 2015

Thanks for the answer. 1st example doesnt work. something wrong this objectmapping in jackson http2objecthandler (could not instantiate Person class)
2nd - worked.

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

2 participants