{"id":13508458,"url":"https://github.com/jr0senblum/jwalk","last_synced_at":"2025-10-21T18:54:24.088Z","repository":{"id":57511008,"uuid":"46581309","full_name":"jr0senblum/jwalk","owner":"jr0senblum","description":"Helper module for working with Erlang proplists, eep 18, map and mochijson-style JSON representations","archived":false,"fork":false,"pushed_at":"2019-11-24T18:18:35.000Z","size":3104,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T18:54:07.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jr0senblum.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":"2015-11-20T19:08:23.000Z","updated_at":"2021-03-12T14:09:17.000Z","dependencies_parsed_at":"2022-09-26T17:51:01.711Z","dependency_job_id":null,"html_url":"https://github.com/jr0senblum/jwalk","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/jr0senblum/jwalk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr0senblum%2Fjwalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr0senblum%2Fjwalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr0senblum%2Fjwalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr0senblum%2Fjwalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jr0senblum","download_url":"https://codeload.github.com/jr0senblum/jwalk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jr0senblum%2Fjwalk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280317282,"owners_count":26309997,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-08-01T02:00:53.279Z","updated_at":"2025-10-21T18:54:24.033Z","avatar_url":"https://github.com/jr0senblum.png","language":"Erlang","funding_links":[],"categories":["JSON"],"sub_categories":[],"readme":"jwalk  \n=====\n## Helper module for working with common Erlang representations of JSON: eep 18, map, \nmochijson-style, and proplists.\n# \n\n[![Build Status](https://travis-ci.org/jr0senblum/jwalk.svg?branch=master)](https://travis-ci.org/jr0senblum/jwalk)\n[![hex.pm version](https://img.shields.io/hexpm/v/jwalk.svg)](https://hex.pm/packages/jwalk)\n# \n\nThis work is inspired by [ej](https://github.com/seth/ej), but handles all common JSON \nrepresentations: eep-18, map, mochijson-style and proplists, the types returned by \n[jsone](https://github.com/sile/jsone), [jiffy](https://github.com/davisp/jiffy), and \n[mochijson](https://github.com/mochi/mochiweb), for example. \n\nAnything good about this is probably due to the contributors and maintainers of ej, anything bad or \nawkward is completely my fault.\n\n### Dependencies  \nThe source code is a single file, and there are no dependencies other than:\n\n* Erlang 19.0 +\n* Rebar3, for building\n\nHex package manager is used for package management.\n\n### QuickStart  \n#### clone\n$ git clone git://github.com/jr0senblum/jwalk.git\n$ cd jwalk\n\n#### compile\n$ make compile\n\n#### run tests\n$ make eunit\n\n#### dialyze\n$ make dialyze\n\n#### Erlang shell\n$ make start\n\n    1\u003e jwalk:get({\"one\"},#{\u003c\u003c\"one\"\u003e\u003e =\u003e 1}).\n    1\n    2\u003e jwalk:get({\"one\"},[{\u003c\u003c\"one\"\u003e\u003e, 1}]).\n    1\n    3\u003e jwalk:get({\"one\"},{[{\u003c\u003c\"one\"\u003e\u003e, 1}]}).\n    1\n    4\u003e  jwalk:get({\"one\"},{struct, [{\u003c\u003c\"one\"\u003e\u003e, 1}]}).\n    1\n\n\n## Functions  \nJwalk functions always take at least two parameters: a first parameter which is a\ntuple of elements representing a Path into a JSON Object, and a second \nparameter which is expected to be a valid JSON representation (map, proplist, etc.).\n\n\n* ``jwalk:delete(Path, Object) -\u003e Result`` \u003c/br\u003e\n Removes the value at the location specified by Path from Object and returns a new structure \u003c/br\u003e\u003c/br\u003e\n* ``jwalk:get(Path, Object) -\u003e Result | undefined``, \u003c/br\u003e\n ``jwalk:get(Path, Object, Default) -\u003e Result | Default``\u003c/br\u003e\n Returns the Value at the specificed Path from Object, or undefined or Default if not found \u003c/br\u003e \u003c/br\u003e\n* ``jwalk:set(Path, Object, Value) -\u003e Result``\u003c/br\u003e\nSets a Value in Object at the specified Path and returns the new structure \u003c/br\u003e \u003c/br\u003e\n* ``jwalk:set_p(Path, Object, Value) -\u003e Result``\u003c/br\u003e\nSets a Value in an Object at the specified Path creating intermediate nodes as necessary and \nreturns the new structure\n\n### Paths  \nPaths into JSON Objects are expressed using a tuple of Path elements, a \nrepresentation of a javascript-like path: i.e.,\n``Obj.weapons.edged.distance``  becomes ``{\"weapons\",\"edged\",\"distance\"}``. \nPath elements representing JSON Member Names can be strings or binary, they \nwill be internally converted to binary regardless.\n\nIn addition to the string/binary representations of Member Names, a Path element can \nbe\n\n* An integer index, or the atoms `first` and `last`, which will select \nan element out of a JSON Array.\n* ``{select, {\"name\",\"value\"|value}}`` which will select a subset of JSON objects \nfrom an Array that have a Member ``{\"Name\": \"Value\"|Value}`` \n* The atom `new`, used in conjunction with the functions set/2 and set_p/2, as the final element of a Path will add the supplied value to the stucture as the first element of an Array, the Array is created if necessary\n\nPath, string elements can be binary or not, they will be converetd to binary regardless.\n\nExamples follow.\n\n### Usage Examples \n    Weapons = [{\u003c\u003c\"edged\"\u003e\u003e, [[{\u003c\u003c\"type\"\u003e\u003e, \u003c\u003c\"swords\"\u003e\u003e}, {\u003c\u003c\"distance\"\u003e\u003e, \u003c\u003c\"medium\"\u003e\u003e}],   \n                              [{\u003c\u003c\"type\"\u003e\u003e, \u003c\u003c\"bayonets\"\u003e\u003e},  {\u003c\u003c\"distance\"\u003e\u003e, \u003c\u003c\"medium\"\u003e\u003e}],\n                              [{\u003c\u003c\"type\"\u003e\u003e, \u003c\u003c\"daggers\"\u003e\u003e}, {\u003c\u003c\"distance\"\u003e\u003e, \u003c\u003c\"close\"\u003e\u003e}]                            \n                            ]                            \n              }].\n              \n\nthen\n\t\n    1\u003e jwalk:get({\"edged\", {select, {\"distance\",\"medium\"}}},Weapons).\n    [[{\u003c\u003c\"type\"\u003e\u003e,\u003c\u003c\"swords\"\u003e\u003e},{\u003c\u003c\"distance\"\u003e\u003e,\u003c\u003c\"medium\"\u003e\u003e}],\n    [{\u003c\u003c\"type\"\u003e\u003e,\u003c\u003c\"bayonets\"\u003e\u003e},{\u003c\u003c\"distance\"\u003e\u003e,\u003c\u003c\"medium\"\u003e\u003e}]]\n\n    2\u003e jwalk:get({\"edged\",{select,{\"distance\",\"medium\"}},1},Weapons).\n    [{\u003c\u003c\"type\"\u003e\u003e,\u003c\u003c\"swords\"\u003e\u003e},{\u003c\u003c\"distance\"\u003e\u003e,\u003c\u003c\"medium\"\u003e\u003e}]\n\n    3\u003e jwalk:get({\"edged\",{select,{\"distance\",\"medium\"}},1,\"type\"},Weapons).\n    \u003c\u003c\"swords\"\u003e\u003e\n\t\n    % setting an element ...\n    4\u003e W2 = jwalk:set({\"edged\",3, \"distance\"}, Weapons, \u003c\u003c\"very close\"\u003e\u003e).\n    [{\u003c\u003c\"edged\"\u003e\u003e,\n     [[{\u003c\u003c\"type\"\u003e\u003e,\u003c\u003c\"swords\"\u003e\u003e},{\u003c\u003c\"distance\"\u003e\u003e,\u003c\u003c\"medium\"\u003e\u003e}],\n      [{\u003c\u003c\"type\"\u003e\u003e,\u003c\u003c\"bayonets\"\u003e\u003e},{\u003c\u003c\"distance\"\u003e\u003e,\u003c\u003c\"medium\"\u003e\u003e}],\n      [{\u003c\u003c\"type\"\u003e\u003e,\u003c\u003c\"daggers\"\u003e\u003e},{\u003c\u003c\"distance\"\u003e\u003e,\u003c\u003c\"very close\"\u003e\u003e}]]}]\n    \n    5\u003e jwalk:get({\"edged\",\"distance\"},W2).\n    [\u003c\u003c\"medium\"\u003e\u003e,\u003c\u003c\"medium\"\u003e\u003e,\u003c\u003c\"very close\"\u003e\u003e]\n\nGiven a map:\n\n    Obj = #{\u003c\u003c\"widget\"\u003e\u003e =\u003e \n            #{\u003c\u003c\"debug\"\u003e\u003e =\u003e \u003c\u003c\"on\"\u003e\u003e,\n              \u003c\u003c\"image\"\u003e\u003e =\u003e \n                  #{\u003c\u003c\"alignment\"\u003e\u003e =\u003e \u003c\u003c\"center\"\u003e\u003e,\n                    \u003c\u003c\"hOffset\"\u003e\u003e =\u003e 250,\n                    \u003c\u003c\"name\"\u003e\u003e =\u003e \u003c\u003c\"sun1\"\u003e\u003e,\n                    \u003c\u003c\"src\"\u003e\u003e =\u003e \u003c\u003c\"Images/Sun.png\"\u003e\u003e,\n                    \u003c\u003c\"vOffset\"\u003e\u003e =\u003e 250},\n              \u003c\u003c\"keys\"\u003e\u003e =\u003e [],\n              \u003c\u003c\"text\"\u003e\u003e =\u003e \n                  #{\u003c\u003c\"alignment\"\u003e\u003e =\u003e \u003c\u003c\"center\"\u003e\u003e,\n                    \u003c\u003c\"data\"\u003e\u003e =\u003e \u003c\u003c\"Click Here\"\u003e\u003e,\n                    \u003c\u003c\"hOffset\"\u003e\u003e =\u003e 250,\n                    \u003c\u003c\"name\"\u003e\u003e =\u003e \u003c\u003c\"text1\"\u003e\u003e,\n                    \u003c\u003c\"onMouseUp\"\u003e\u003e =\u003e \u003c\u003c\"sun1.opacity = (sun1.opacity / 100) * 90;\"\u003e\u003e,\n                    \u003c\u003c\"size\"\u003e\u003e =\u003e 36,\n                    \u003c\u003c\"style\"\u003e\u003e =\u003e \u003c\u003c\"bold\"\u003e\u003e,\n                    \u003c\u003c\"vOffset\"\u003e\u003e =\u003e 100},\n              \u003c\u003c\"values\"\u003e\u003e =\u003e [1,2,3,4,5],\n              \u003c\u003c\"version\"\u003e\u003e =\u003e \u003c\u003c\"1\"\u003e\u003e,\n              \u003c\u003c\"window\"\u003e\u003e =\u003e \n                  #{\u003c\u003c\"height\"\u003e\u003e =\u003e 500,\n                    \u003c\u003c\"name\"\u003e\u003e =\u003e \u003c\u003c\"main_window\"\u003e\u003e,\n                    \u003c\u003c\"title\"\u003e\u003e =\u003e \u003c\u003c\"Sample Konfabulator Widget\"\u003e\u003e,\n                    \u003c\u003c\"width\"\u003e\u003e =\u003e 500}}}.\n\nthen\n    \n\n    1\u003e jwalk:get({\"widget\",\"debug\"},Obj).\n    \u003c\u003c\"on\"\u003e\u003e\n\t\n\t2\u003e jwalk:get({\"widget\",\"text\"},Obj).\n\t#{\u003c\u003c\"alignment\"\u003e\u003e =\u003e \u003c\u003c\"center\"\u003e\u003e,\n  \t  \u003c\u003c\"data\"\u003e\u003e =\u003e \u003c\u003c\"Click Here\"\u003e\u003e,\n  \t  \u003c\u003c\"hOffset\"\u003e\u003e =\u003e 250,\n  \t  \u003c\u003c\"name\"\u003e\u003e =\u003e \u003c\u003c\"text1\"\u003e\u003e,\n  \t  \u003c\u003c\"onMouseUp\"\u003e\u003e =\u003e \u003c\u003c\"sun1.opacity = (sun1.opacity / 100) * 90;\"\u003e\u003e,\n  \t  \u003c\u003c\"size\"\u003e\u003e =\u003e 36,\n  \t  \u003c\u003c\"style\"\u003e\u003e =\u003e \u003c\u003c\"bold\"\u003e\u003e,\n  \t  \u003c\u003c\"vOffset\"\u003e\u003e =\u003e 100}\n      \nset_p creates intermediary nodes: \n\n\t1\u003e jwalk:set_p({\"users\", {select, {\"name\", \"sebastian\"}}, \"location\"}, #{}, \u003c\u003c\"Germany\"\u003e\u003e).\n    #{\u003c\u003c\"users\"\u003e\u003e =\u003e [#{\u003c\u003c\"location\"\u003e\u003e =\u003e \u003c\u003c\"Germany\"\u003e\u003e,\u003c\u003c\"name\"\u003e\u003e =\u003e \u003c\u003c\"sebastian\"\u003e\u003e}]}\n\n\t2\u003e jwalk:set_p({\"users\", {select, {\"name\", \"sebastian\"}}, \"location\"}, [{}],    \u003c\u003c\"Germany\"\u003e\u003e).\n\t[{\u003c\u003c\"users\"\u003e\u003e,\n\t  [[{\u003c\u003c\"name\"\u003e\u003e,\u003c\u003c\"sebastian\"\u003e\u003e},\n            {\u003c\u003c\"location\"\u003e\u003e,\u003c\u003c\"Germany\"\u003e\u003e}]]}]\n\n    3\u003e jwalk:set_p({\"users\", {select, {\"name\", \"sebastian\"}}, \"location\"}, {[]},    \u003c\u003c\"Germany\"\u003e\u003e).\n\t{[{\u003c\u003c\"users\"\u003e\u003e,\n   \t  [{[{\u003c\u003c\"name\"\u003e\u003e,\u003c\u003c\"sebastian\"\u003e\u003e},\n             {\u003c\u003c\"location\"\u003e\u003e,\u003c\u003c\"Germany\"\u003e\u003e}]}]}]}\n\n    4\u003e jwalk:set_p({\"users\", {select, {\"name\", \"sebastian\"}}, \"location\"}, {struct,[]}, \u003c\u003c\"Germany\"\u003e\u003e).\n    {struct,[{\u003c\u003c\"users\"\u003e\u003e,\n        [{struct,[{\u003c\u003c\"name\"\u003e\u003e,\u003c\u003c\"sebastian\"\u003e\u003e},\n                  {\u003c\u003c\"location\"\u003e\u003e,\u003c\u003c\"Germany\"\u003e\u003e}]}]}]}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjr0senblum%2Fjwalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjr0senblum%2Fjwalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjr0senblum%2Fjwalk/lists"}