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

ponzu does not handle underscores in the variable names very well #113

Closed
devdavidkarlsson opened this issue Apr 10, 2017 · 2 comments
Closed

Comments

@devdavidkarlsson
Copy link

`{
data: [
{
uuid: "574cb970-2863-4e7a-b9da-a440987dc55e",
id: 1,
slug: "item-id-574cb970-2863-4e7a-b9da-a440987dc55e",
timestamp: 1491778146000,
updated: 1491821466260,
c_o_n_f_i_r_m_h_e_a_d_i_n_g_p_a_p_e_r_s_i_g_n_i_n_g: "lalalal",
c_o_n_f_i_r_m_b_o_d_y_p_a_p_e_r_s_i_g_n_i_n_g: "",

Why all the underscores in the repsonse from the API?

When creating a content with: CONFIRM_HEADING_PAPER_SIGNING:"string" this is what gets shown in the UI: CONFIRMHEADINGPAPERSIGNING. and the JSON response is shown above...

Ludacris underscorestrings.... why....

@nilslice
Copy link
Contributor

nilslice commented Apr 10, 2017

Hi @devdavidkarlsson -

In an attempt to make the type and field name parser adhere to common Go idioms, the character after a capital letter is separated by an underscore in the JSON tag name. For example:

FieldName -> field_name
and inversely,
field_name -> FieldName

In the Ponzu generator, you should type in these names as they would appear in your code. It's very uncommon in Go to use a field name like the one you provided.

@devdavidkarlsson
Copy link
Author

Thanks for clarifying...

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