{"id":19098900,"url":"https://github.com/ddliu/fractal","last_synced_at":"2026-04-12T08:40:10.063Z","repository":{"id":57528792,"uuid":"157048822","full_name":"ddliu/fractal","owner":"ddliu","description":"Fractal is a Go package that makes it easy to work with dynamic and nested data types, with encoding/decoding support.","archived":false,"fork":false,"pushed_at":"2020-05-25T11:35:43.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-03T01:21:39.014Z","etag":null,"topics":["golang","json","map","marshal","path","struct","unmarshal"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/ddliu.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":"2018-11-11T05:00:05.000Z","updated_at":"2022-01-19T05:43:24.000Z","dependencies_parsed_at":"2022-09-10T17:10:10.398Z","dependency_job_id":null,"html_url":"https://github.com/ddliu/fractal","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddliu%2Ffractal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddliu%2Ffractal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddliu%2Ffractal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddliu%2Ffractal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddliu","download_url":"https://codeload.github.com/ddliu/fractal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240154526,"owners_count":19756474,"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":["golang","json","map","marshal","path","struct","unmarshal"],"created_at":"2024-11-09T03:47:54.190Z","updated_at":"2026-04-12T08:40:05.029Z","avatar_url":"https://github.com/ddliu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fractal\n\n[![Travis](https://img.shields.io/travis/ddliu/fractal.svg?style=flat-square)](https://travis-ci.org/ddliu/fractal)\n[![godoc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/ddliu/fractal)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ddliu/fractal)](https://goreportcard.com/report/github.com/ddliu/fractal)\n[![cover.run](https://cover.run/go/github.com/ddliu/fractal.svg?style=flat\u0026tag=golang-1.10)](https://cover.run/go?tag=golang-1.10\u0026repo=github.com%2Fddliu%2Ffractal)\n\n\nFractal is a Go package that makes it easy to work with dynamic and nested data types, with encoding/decoding support.\n\n## Features\n\n- Nested data type\n- Dot path support\n- JSON encoding/decoding\n- Simple template replacement\n- Inplace update\n- Common data type support: Struct, Map...\n\n## Install\n\n```\ngo get -u github.com/ddliu/fractal\n```\n\n## Usage\n\nWork with struct\n\n```go\ndata := myStruct {\n    Key1: \"Value1\",\n    Key2: anotherStruct {\n        Key3: \"Value3\"\n    }\n}\n\n// Create context\nctx := fractal.New(data)\nprintln(ctx.String(\"Key2.Key3\"))\n// output: Value3\n```\n\nWork with json\n\n```go\nctx := fractal.FromJson([]byte(`{\"key1\": \"value1\", \"key2\": {\"key3\": \"value3\"}}`))\nprintln(ctx.String(\"key2.key3\"))\n```\n\nOr with JSON unmarshal\n\n```go\nvar ctx fractal.Context\njson.Unmarshal([]byte(`{\"key1\": \"value1\", \"key2\": {\"key3\": \"value3\"}}`), \u0026ctx)\nprintln(ctx.String(\"key2.key3\"))\n```\n\nWork with map\n\n```go\nctx := fractal.New(map[string]interface{\n    \"key1\": \"value1\",\n    \"key2\": \"value2\",\n})\n```\n\nUpdate:\n\n```go\nctx.SetValue(\"key2.new_key\", 3)\n```\n\nSimple template:\n\n```go\ntpl := `Author: ${author.name}; License: ${license}; `\n\nc := New(nil)\nc.SetValue(\"author\", map[string]string{\n    \"name\":  \"Dong\",\n    \"email\": \"test@example.com\",\n})\n\nc.SetValue(\"license\", \"MIT\")\n\nprintln(c.Tpl(tpl))\n\n// output: Author: Dong; License: MIT; \n```\n\n## Dot Notation\n\n- `a.b`: Notation access\n- `a.b.1`: Array index\n- `a.b.length()`: Length of array or object","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddliu%2Ffractal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddliu%2Ffractal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddliu%2Ffractal/lists"}