{"id":18454814,"url":"https://github.com/paulbouwer/scriptcs-objectdumper","last_synced_at":"2025-04-15T14:48:11.426Z","repository":{"id":139108350,"uuid":"18316837","full_name":"paulbouwer/scriptcs-objectdumper","owner":"paulbouwer","description":null,"archived":false,"fork":false,"pushed_at":"2014-04-08T08:38:52.000Z","size":624,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T21:23:05.644Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulbouwer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-01T03:42:24.000Z","updated_at":"2023-08-29T10:50:32.000Z","dependencies_parsed_at":"2023-04-03T18:06:59.611Z","dependency_job_id":null,"html_url":"https://github.com/paulbouwer/scriptcs-objectdumper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulbouwer%2Fscriptcs-objectdumper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulbouwer%2Fscriptcs-objectdumper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulbouwer%2Fscriptcs-objectdumper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulbouwer%2Fscriptcs-objectdumper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulbouwer","download_url":"https://codeload.github.com/paulbouwer/scriptcs-objectdumper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661722,"owners_count":21141450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T08:06:14.092Z","updated_at":"2025-04-15T14:48:11.408Z","avatar_url":"https://github.com/paulbouwer.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"scriptcs-objectdumper\n=====================\n\n# About #\n\nThis [Script Pack](https://github.com/scriptcs/scriptcs/wiki) for [scriptcs](http://scriptcs.net/) provides object dumper behaviour.\n\nThis script pack allows the structure of objects to be dumped from within the REPL or scripts. It utilises JSON.Net for serialisation. A number of options are provided:\n\n- Object References (Include/Exclude)\n- Output Format (PrettyPrint/Compact)\n- Null Values (Include/Exclude)\n\n# Installation #\n\nInstall the nuget package by running\n\n\tscriptcs -install ScriptCs.ObjectDumper.ScriptPack\n\n\n# Usage #\n\nObtain a reference to the Script Pack and configure using one or more build methods. Finally call Build() to construct the dumper.\n\n    var dumper = Require\u003cObjectDumper\u003e()\n\t\t.Compact()\n\t\t.Build();\n\nYou can then dump an object as follows:\n\n\tpublic class Person  \n\t{\n\t\tpublic string FirstName {get; set;}\n\t\tpublic string LastName {get;set;}\n\t}\n\tvar person = new Person { FirstName = \"Paul\", LastName = \"Bouwer\" }\n\n\tConsole.WriteLine( dumper.Dump(person) );\n\n# Configuration #\n\nThe object dumper can be build by combining one or more of the following methods. Remember to call Build() at the end of the chain to construct the dumper.\n\nThe following object will be used to demonstrate the build methods:\n\n\tpublic class Person  \n\t{\n\t\tpublic string FirstName {get; set;}\n\t\tpublic string LastName {get;set;}\n\t\tpublic Address Address1 {get;set;}\n\t\tpublic Address Address2 {get;set;}\n\t}\n\tpublic class Address \n\t{\n\t\tpublic string Line1 {get;set;}\n\t\tpublic string Line2 {get;set;}\n\t}\t\n\tvar address = new Address { Line1 = \"Line1\" };\n\tvar person = new Person { FirstName = \"Paul\", LastName = \"Bouwer\", Address1 = address, Address2 = address};\n\n## Object References ##\n\nYou can include or exclude object references. The serialiser (JSON.NET) used can add references when the same object is referenced multiple times within the object being dumped.\n\n**IncludeObjectReferences()**\n\n\tvar dumper = Require\u003cObjectDumper\u003e()\n\t  .IncludeObjectReferences()\n\t  .Build();\n\nResults in the following:\n\n\t{\n\t  \"$id\": \"1\",\n\t  \"FirstName\": \"Paul\",\n\t  \"LastName\": \"Bouwer\",\n\t  \"Address1\": {\n\t    \"$id\": \"2\",\n\t    \"Line1\": \"Line1\"\n\t  },\n\t  \"Address2\": {\n\t    \"$ref\": \"2\"\n\t  }\n\t}\n\n**ExcludeObjectReferences()**\n\n\tvar dumper = Require\u003cObjectDumper\u003e()\n\t  .ExcludeObjectReferences()\n\t  .Build();\n\nResults in the following:\n\n\t{\n\t  \"FirstName\": \"Paul\",\n\t  \"LastName\": \"Bouwer\",\n\t  \"Address1\": {\n\t    \"Line1\": \"Line1\",\n\t    \"Line2\": null\n\t  },\n\t  \"Address2\": {\n\t    \"Line1\": \"Line1\",\n\t    \"Line2\": null\n\t  }\n\t}\n\n## Formatting ##\n\nYou can format the dumped output as pretty printed or compact. Here is what that looks like:\n\n**PrettyPrint()**\n\n\tvar dumper = Require\u003cObjectDumper\u003e()\n\t  .PrettyPrint()\n\t  .Build();\n\nResults in the following:\n\n\t{\n\t  \"FirstName\": \"Paul\",\n\t  \"LastName\": \"Bouwer\",\n\t  \"Address1\": {\n\t    \"Line1\": \"Line1\",\n\t    \"Line2\": null\n\t  },\n\t  \"Address2\": {\n\t    \"Line1\": \"Line1\",\n\t    \"Line2\": null\n\t  }\n\t}\n\t\n**Compact()**\n\n\tvar dumper = Require\u003cObjectDumper\u003e()\n\t  .Compact()\n\t  .Build();\n\nResults in the following:\n\n\t{\"FirstName\":\"Paul\",\"LastName\":\"Bouwer\",\"Address1\":{\"Line1\":\"Line1\",\"Line2\":null},\"Address2\":{\"Line1\":\"Line1\",\"Line2\":null}}\n\n## Null Values ##\n\nYou can also include or exclude null values from the dumped object. Here is what that looks like:\n\n**IncludeNullValues()**\n\n\tvar dumper = Require\u003cObjectDumper\u003e()\n\t  .IncludeNullValues()\n\t  .Build();\n\nResults in the following:\n\n\t{\n\t  \"FirstName\": \"Paul\",\n\t  \"LastName\": \"Bouwer\",\n\t  \"Address1\": {\n\t    \"Line1\": \"Line1\",\n\t    \"Line2\": null\n\t  },\n\t  \"Address2\": {\n\t    \"Line1\": \"Line1\",\n\t    \"Line2\": null\n\t  }\n\t}\n\n**ExcludeNullValues()**\n\n\tvar dumper = Require\u003cObjectDumper\u003e()\n\t  .ExcludeNullValues()\n\t  .Build();\n\nResults in the following:\n\n\t{\n\t  \"FirstName\": \"Paul\",\n\t  \"LastName\": \"Bouwer\",\n\t  \"Address1\": {\n\t    \"Line1\": \"Line1\",\n\t  },\n\t  \"Address2\": {\n\t    \"Line1\": \"Line1\",\n\t  }\n\t}\n\n## Defaults ##\n\nThe following options are the defaults:\n\n- Object References - ExcludeObjectReferences()\n- Formatting - PrettyPrint()\n- Null Values - IncludeNullValues()\n\n# Sample #\n\nA example of how to use the Script Pack is available in the ``sample`` folder. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulbouwer%2Fscriptcs-objectdumper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulbouwer%2Fscriptcs-objectdumper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulbouwer%2Fscriptcs-objectdumper/lists"}