Giter Site home page Giter Site logo

j2s's Introduction

Godocs Go Report Card Open Source Helpers Release

jsonToStruct

Golang code generator for creating struct from json.

INSTALLATION

go get github.com/mayur-tolexo/j2s

Tags:

  • -ip=input.json [Input File (default "input.json")]
  • -op=bakery.go [Output File (default "output.go")]
  • -name=Bakery [Structure Name (default "User")]
  • -reuse=1 [if you want to reuse struct having same fields (default 0)]

Create Struct from console json.

Command Output
Screenshot 2019-11-16 at 12 31 41 AM Screenshot 2019-11-16 at 12 32 14 AM

Create struct from json input file.

Screenshot 2019-11-16 at 12 33 10 AM

Input Output
Screenshot 2019-11-16 at 12 32 37 AM Screenshot 2019-11-16 at 12 33 24 AM

j2s's People

Contributors

mayur-tolexo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

isabst pengchen98

j2s's Issues

Error in converting a valid JSON

Error: 2019/12/10 20:18:40 template: template:7:15: executing "template" at <TypeOf $structName $jsonName $val>: error calling TypeOf: interface conversion: interface {} is []interface {}, not float64

Command executed:
image

Input JSON:

{
	"sleep": {
		"sleep_score": {
			"process_state": "PROCESSING",
			"state_message": "abajbasbfiba",
			"score": 1234
		},
		"sleep_time_sec": 312,
		"resting_hr": 321.421,
		"survey": {
			"date": 19951111,
			"timestamp": 4124127982,
			"survey_type": "UNKNOW",
			"questions": [{
				"id": 1,
				"question_text": "What is your name?",
				"answer": {
					"percentage": "<2.1 || Null >",
					"strings": "<[list of string] || Null>"
				}
			}],
			"survey_id": "faskbkjab"
		},
		"stages": {
			"awake_percentage": 21,
			"rem_percentage": 321,
			"light_percentage": 321,
			"deep_percentage": 232,
			"stages": [{
				"tag": "UNKNOWN_TAG",
				"start_ts": 321,
				"end_ts": 321
			}]
		},
		"biometrics": {
			"hr_graph": {
				"min": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"max": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"avg": 6345.34,
				"data_points": [{
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}, {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}]
			},
			"hrv_graph": {
				"min": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"max": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"avg": 6345.34,
				"data_points": [{
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}, {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}]
			},
			"spo2_graph": {
				"min": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"max": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"avg": 6345.34,
				"data_points": [{
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}, {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}]
			},
			"resp_graph": {
				"min": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"max": {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				},
				"avg": 6345.34,
				"data_points": [{
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}, {
					"timestamp": 312,
					"timezone": 312,
					"value": 312.12
				}]
			}
		},
		"disturbances": {
			"snoring_graph": {
				"none_percentage": "32.321[deprecated = true]",
				"mild_percentage": "32.321[deprecated = true]",
				"moderate_percentage": "32.321[deprecated = true]",
				"severe_percentage": "32.321[deprecated = true]",
				"stages": [{
					"disturbance": "MILD [deprecated = true]",
					"point": {
						"timestamp": 312,
						"timezone": 312,
						"value": 312.12
					},
					"hex_color": "nlnlnklnlsd"
				}],
				"tags": {
					"hex_color": "ndkjfndjaks",
					"title": "ndkjfndjaks",
					"subtitle": "ndkjfndjaks"
				}
			},
			"arm_graph": {
				"none_percentage": "32.321[deprecated = true]",
				"mild_percentage": "32.321[deprecated = true]",
				"moderate_percentage": "32.321[deprecated = true]",
				"severe_percentage": "32.321[deprecated = true]",
				"stages": [{
					"disturbance": "MILD [deprecated = true]",
					"point": {
						"timestamp": 312,
						"timezone": 312,
						"value": 312.12
					},
					"hex_color": "nlnlnklnlsd"
				}],
				"tags": {
					"hex_color": "ndkjfndjaks",
					"title": "ndkjfndjaks",
					"subtitle": "ndkjfndjaks"
				}
			},
			"leg_graph": {
				"none_percentage": "32.321[deprecated = true]",
				"mild_percentage": "32.321[deprecated = true]",
				"moderate_percentage": "32.321[deprecated = true]",
				"severe_percentage": "32.321[deprecated = true]",
				"stages": [{
					"disturbance": "MILD [deprecated = true]",
					"point": {
						"timestamp": 312,
						"timezone": 312,
						"value": 312.12
					},
					"hex_color": "nlnlnklnlsd"
				}],
				"tags": {
					"hex_color": "ndkjfndjaks",
					"title": "ndkjfndjaks",
					"subtitle": "ndkjfndjaks"
				}
			},
			"kicks_graph": {
				"none_percentage": "32.321[deprecated = true]",
				"mild_percentage": "32.321[deprecated = true]",
				"moderate_percentage": "32.321[deprecated = true]",
				"severe_percentage": "32.321[deprecated = true]",
				"stages": [{
					"disturbance": "MILD [deprecated = true]",
					"point": {
						"timestamp": 312,
						"timezone": 312,
						"value": 312.12
					},
					"hex_color": "nlnlnklnlsd"
				}],
				"tags": {
					"hex_color": "ndkjfndjaks",
					"title": "ndkjfndjaks",
					"subtitle": "ndkjfndjaks"
				}
			}
		},
		"metrics": [{
			"name": "sofafads",
			"is_editable": false,
			"value": "It is of type oneof so refer SleepMetricValue in sleeps.proto"
		}],
		"sleep_onset": 41234,
		"wake_up_time": 312,
		"timezone": 312,
		"resting_hrv": 312.4123,
		"score_factors": {
			"title": "sgsdg",
			"color": "COLOR_WHITE",
			"value": 312.423,
			"description": "gsdgsd"
		},
		"score_penalty": {
			"name": "sofafads",
			"value": "fdsfd"
		},

		"bathroom_break_timestamps": [312, 312, 321, 432, 54],
		"position_info": {
			"positions": [{
				"state": "SLEEP_POS_LEFT",
				"state_percentage": 32143,
				"state_duration_in_seconds": 3143434546
			}],
			"position_intervals": {
				"state": "SLEEP_POS_LEFT",
				"start_ts": 4141234,
				"end_ts": 4325
			}
		},
		"apnea_info": {
			"total_events": 43413,
			"events": [{
				"start_ts": 321,
				"end_ts": 4325
			}]
		},
		"temperature_variations": [{
			"timestamp": 312,
			"timezone": 312,
			"value": 312.6435
		}],

		"status_with_msg": {
			"status": "SLEEP_START_ADD",
			"msg": "djkfbdshfbas"
		},
		"processing": false,

		"notifications": [{
			"title": "ndkjfndjaks",
			"description": "ndkjfndjaks",
			"type": "NET_SLEEP_LAB"
		}]
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.