question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to generate non-anonymous structs as output

See original GitHub issue

I have found this application extremely useful. Thank you for your time and effort!

However, to enable the re-use of the nested structures ( not just for parsing ) , It would be great to have an option to generate named structs. Instead of this

type ConfigurationData struct {
	ApplicationDisplay struct {
		Title          string `json:"title"`
		Subtitle       string `json:"subtitle"`
		WelcomeMessage string `json:"welcomeMessage"`
	} `json:"applicationDisplay"`
}

it would generate

type ApplicationDisplay struct {
    Title          string `json:"title"`
    Subtitle       string `json:"subtitle"`
    WelcomeMessage string `json:"welcomeMessage"`
}

type ConfigurationData struct {
    ApplicationDisplay ApplicationDisplay `json:"applicationDisplay"`
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:12
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mike-hosseinicommented, Mar 5, 2019

@suntong

  1. Open your web browser console, preferably Google Chrome.
  2. Copy and paste the contents of json-to-go.js and hit enter.
  3. Replace the test JSON below with yours and once you have done that, hit enter and you should get your Go code.
console.log(
    jsonToGo(`
    {
        "test": "a"
    }
    `).go
)
1reaction
mholtcommented, Mar 5, 2019

I haven’t deployed the latest on master yet, but you’re welcome to use it: https://github.com/mholt/json-to-go/pull/49

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using an anonymous struct vs a named struct with typedef
One situation where you want the non-anonymous is when you want pointers to an object of the same type, like in a linked...
Read more >
Structs in Go (Golang) | Detailed Tutorial with Examples
A struct is a user defined data type which represents a collections of fields. Structs can either be named or anonymous.
Read more >
ANSI-C nested, anonymous struct and union fail to produce ...
Given the examples below, I've not found a way to have doxygen generate ideal output for types with nested anonymous structs and unions, ......
Read more >
Kernel-doc comments — The Linux Kernel documentation
The kernel-doc structure is extracted from the comments, and proper Sphinx C Domain function and type descriptions with anchors are generated from them....
Read more >
Anonymous Union and Structure in C
Anonymous unions/structures are also known as unnamed unions/structures as they don't have names. Since there is no names, direct objects(or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found