Code Monkey home page Code Monkey logo

json4go's People

Contributors

dijp avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

rabarar loutian

json4go's Issues

Parse2JsonArray error, retur nil

func calcNodeScoreTest(ip string) error {
	// call url
	body := "[{\"read\":\"2016-12-05T08:12:50.796867949Z\",\"preread\":\"2016-12-05T08:12:49.852566599Z\",\"pids_stats\":{},\"blkio_stats\":{\"io_service_bytes_recursive\":[],\"io_serviced_recursive\":[],\"io_queue_recursive\":[],\"io_service_time_recursive\":[],\"io_wait_time_recursive\":[],\"io_merged_recursive\":[],\"io_time_recursive\":[],\"sectors_recursive\":[]},\"num_procs\":0,\"storage_stats\":{},\"cpu_stats\":{\"cpu_usage\":{\"total_usage\":931578342,\"percpu_usage\":[194554633,446908218,85914365,204201126],\"usage_in_kernelmode\":780000000,\"usage_in_usermode\":120000000},\"system_cpu_usage\":109986170000000,\"throttling_data\":{\"periods\":0,\"throttled_periods\":0,\"throttled_time\":0}},\"precpu_stats\":{\"cpu_usage\":{\"total_usage\":931578342,\"percpu_usage\":[194554633,446908218,85914365,204201126],\"usage_in_kernelmode\":780000000,\"usage_in_usermode\":120000000},\"system_cpu_usage\":109982210000000,\"throttling_data\":{\"periods\":0,\"throttled_periods\":0,\"throttled_time\":0}},\"memory_stats\":{\"usage\":102400,\"max_usage\":569344,\"stats\":{\"active_anon\":61440,\"active_file\":0,\"cache\":0,\"dirty\":0,\"hierarchical_memory_limit\":8796093018112,\"inactive_anon\":0,\"inactive_file\":0,\"mapped_file\":0,\"pgfault\":24956,\"pgmajfault\":0,\"pgpgin\":9933,\"pgpgout\":9918,\"rss\":61440,\"rss_huge\":0,\"total_active_anon\":61440,\"total_active_file\":0,\"total_cache\":0,\"total_dirty\":0,\"total_inactive_anon\":0,\"total_inactive_file\":0,\"total_mapped_file\":0,\"total_pgfault\":24956,\"total_pgmajfault\":0,\"total_pgpgin\":9933,\"total_pgpgout\":9918,\"total_rss\":61440,\"total_rss_huge\":0,\"total_unevictable\":0,\"total_writeback\":0,\"unevictable\":0,\"writeback\":0},\"limit\":970485760},\"name\":\"/test1.10.it8zxjz40ghczwxbuf6o9kqx1\",\"id\":\"fd1a36c95fcadd60d193b6e3cf62a55b67b066d7d07da2487ec9deadf303cb6b\",\"networks\":{\"eth0\":{\"rx_bytes\":101501,\"rx_packets\":337,\"rx_errors\":0,\"rx_dropped\":4,\"tx_bytes\":1535,\"tx_packets\":15,\"tx_errors\":0,\"tx_dropped\":0}}},{\"read\":\"2016-12-05T08:12:52.796912007Z\",\"preread\":\"2016-12-05T08:12:51.876956563Z\",\"pids_stats\":{},\"blkio_stats\":{\"io_service_bytes_recursive\":[{\"major\":179,\"minor\":0,\"op\":\"Read\",\"value\":835584},{\"major\":179,\"minor\":0,\"op\":\"Write\",\"value\":0},{\"major\":179,\"minor\":0,\"op\":\"Sync\",\"value\":0},{\"major\":179,\"minor\":0,\"op\":\"Async\",\"value\":835584},{\"major\":179,\"minor\":0,\"op\":\"Total\",\"value\":835584}],\"io_serviced_recursive\":[{\"major\":179,\"minor\":0,\"op\":\"Read\",\"value\":14},{\"major\":179,\"minor\":0,\"op\":\"Write\",\"value\":0},{\"major\":179,\"minor\":0,\"op\":\"Sync\",\"value\":0},{\"major\":179,\"minor\":0,\"op\":\"Async\",\"value\":14},{\"major\":179,\"minor\":0,\"op\":\"Total\",\"value\":14}],\"io_queue_recursive\":[],\"io_service_time_recursive\":[],\"io_wait_time_recursive\":[],\"io_merged_recursive\":[],\"io_time_recursive\":[],\"sectors_recursive\":[]},\"num_procs\":0,\"storage_stats\":{},\"cpu_stats\":{\"cpu_usage\":{\"total_usage\":1001417913,\"percpu_usage\":[218304638,357942516,203459071,221711688],\"usage_in_kernelmode\":880000000,\"usage_in_usermode\":70000000},\"system_cpu_usage\":109994150000000,\"throttling_data\":{\"periods\":0,\"throttled_periods\":0,\"throttled_time\":0}},\"precpu_stats\":{\"cpu_usage\":{\"total_usage\":1001417913,\"percpu_usage\":[218304638,357942516,203459071,221711688],\"usage_in_kernelmode\":880000000,\"usage_in_usermode\":70000000},\"system_cpu_usage\":109990160000000,\"throttling_data\":{\"periods\":0,\"throttled_periods\":0,\"throttled_time\":0}},\"memory_stats\":{\"usage\":897024,\"max_usage\":1392640,\"stats\":{\"active_anon\":61440,\"active_file\":552960,\"cache\":835584,\"dirty\":0,\"hierarchical_memory_limit\":8796093018112,\"inactive_anon\":0,\"inactive_file\":282624,\"mapped_file\":622592,\"pgfault\":24963,\"pgmajfault\":6,\"pgpgin\":9980,\"pgpgout\":9761,\"rss\":61440,\"rss_huge\":0,\"total_active_anon\":61440,\"total_active_file\":552960,\"total_cache\":835584,\"total_dirty\":0,\"total_inactive_anon\":0,\"total_inactive_file\":282624,\"total_mapped_file\":622592,\"total_pgfault\":24963,\"total_pgmajfault\":6,\"total_pgpgin\":9980,\"total_pgpgout\":9761,\"total_rss\":61440,\"total_rss_huge\":0,\"total_unevictable\":0,\"total_writeback\":0,\"unevictable\":0,\"writeback\":0},\"limit\":970485760},\"name\":\"/test1.11.nzlw2p3bhyh9seva8xuh15s7l\",\"id\":\"4a8b63571f313c245dad5fc189421d0472136e7ed90af276c71a06ca56084b33\",\"networks\":{\"eth0\":{\"rx_bytes\":99510,\"rx_packets\":333,\"rx_errors\":0,\"rx_dropped\":5,\"tx_bytes\":2940,\"tx_packets\":20,\"tx_errors\":0,\"tx_dropped\":0}}}]"

	stats := json4go.Parse2JsonArray(body)
	fmt.Println(stats)
	statsNum := stats.GetLength()

	return nil
}

output is :

<nil>
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x40111c]

goroutine 1 [running]:
panic(0x5f6100, 0xc42000c130)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
main.calcNodeScoreTest(0x635714, 0xc, 0x0, 0xc42000d080)
	/home/test/Workspace/go/test.go:131 +0x8c
main.main()
	/home/test/Workspace/go/test.go:27 +0x36
exit status 2

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.