{"id":17032955,"url":"https://github.com/up9cloud/serde_json_lodash","last_synced_at":"2026-05-04T19:35:59.490Z","repository":{"id":147293427,"uuid":"324423757","full_name":"up9cloud/serde_json_lodash","owner":"up9cloud","description":"serde_json::Value with lodash.js spec, makes life easier","archived":false,"fork":false,"pushed_at":"2022-01-23T13:30:27.000Z","size":168,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T21:18:04.162Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/up9cloud.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-25T19:48:37.000Z","updated_at":"2022-06-14T08:03:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"4ef2f6bd-abf4-4875-b0fc-17054e446d4d","html_url":"https://github.com/up9cloud/serde_json_lodash","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/up9cloud/serde_json_lodash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up9cloud%2Fserde_json_lodash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up9cloud%2Fserde_json_lodash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up9cloud%2Fserde_json_lodash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up9cloud%2Fserde_json_lodash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/up9cloud","download_url":"https://codeload.github.com/up9cloud/serde_json_lodash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/up9cloud%2Fserde_json_lodash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32622268,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"ssl_error","status_checked_at":"2026-05-04T10:08:02.005Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-10-14T08:31:11.773Z","updated_at":"2026-05-04T19:35:59.468Z","avatar_url":"https://github.com/up9cloud.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# serde_json_lodash\n\n[![Documentation](https://img.shields.io/crates/v/serde_json_lodash?label=latest)](https://docs.rs/serde_json_lodash)\n[![build status](https://github.com/up9cloud/serde_json_lodash/workflows/CI/badge.svg?branch=main\u0026event=push)](https://github.com/up9cloud/serde_json_lodash/actions)\n![Downloads](https://img.shields.io/crates/d/serde_json_lodash.svg)\n\n[serde_json::Value](https://docs.serde.rs/serde_json/value/enum.Value.html) with [lodash.js](https://github.com/lodash/lodash) spec, makes life easier.\n\n## Usage\n\n\u003e Cargo.toml\n\n```toml\n[dependencies]\nserde_json_lodash = \"0.1\"\n```\n\n\u003e main.rs\n\n```rust\n#[macro_use] extern crate serde_json_lodash;\nuse serde_json::json;\nfn main() {\n  // macro style, optional parameters\n  assert_eq!(\n    merge!(json!({'a':1}), json!({'b':2}), json!({'c':3})),\n    json!({'a': 1, 'b': 2, 'c': 3})\n  );\n\n  // fn style, fixed parameters\n  use serde_json_lodash::merge;\n  assert_eq!(\n    merge(json!({'a':1}), json!({'b':2})),\n    json!({'a': 1, 'b': 2})\n  );\n\n  // `x_`, `_x` helpers for simple types\n  assert_eq!(capitalize!(json!(\"FRED\")), json!(\"Fred\"));\n  assert_eq!(x_capitalize!(\"FRED\"), json!(\"Fred\"));\n  assert_eq!(capitalize_x!(json!(\"FRED\")), \"Fred\".to_owned());\n  assert_eq!(x_capitalize_x!(\"FRED\"), \"Fred\".to_owned());\n}\n```\n\n## Concepts\n\nAll implements should be same as lodash as possible\n\nHow?\n\n- Every function from lodash.js should be implemented both `fn` and `macro`\n  - marco is for optional parameters usages\n- The main inputs and return values should be *`serde_json::Value`*, excepts:\n  - Inputs:\n    - If the input parameters are options, not data, always using *primitive type* instead Value\n      - e.q. `_.chunk(array, [size=1])` =\u003e `::chunk(json!([1,2,3]), 2)`, size should be `usize`, not `Value::Number`\n    - Some cases we use *`std::ops::Fn`* as input parameter\n      - e.q. `_.findIndex(array, predicate, ...)` =\u003e `::find_index(..., predicate: fn(\u0026Value) -\u003e bool, ...)`\n  - Retune values:\n    - If return value is statistic, using *primitive type* instead Value\n      - e.q. `_.findIndex(...)` =\u003e `::find_index(...) -\u003e isize`, return value should be `isize`, not `Value::Number`\n    - Because there is no `undefined` type in serde_json, so if the original function return `undefined`, the ported version should return Value::Null\n- If the original function allows optional parameters:\n  - known amount, then the ported fn should *should be as required*\n    - e.q. `_.get(object, path, [defaultValue])` =\u003e `::get(object, path, defaultValue)`\n  - infinity amount, the ported fn should *only keep one, and no more optionals*\n    - e.q. `_.merge(object, [...sources])` =\u003e `::merge(object, source)`, but macro could `::merge!(object, source1, source2, ...)`\n- It might implement helper functions, for different input and output types:\n  - with *`x_` prefix*: input is not Value, will be downgrade type\n    - e.q. `x_capitalize(\u0026str) -\u003e Value`\n  - with *`_x` suffix*: output is not Value, will be downgrade type\n    - e.q. `capitalize_x(Value) -\u003e String`\n  - with *both `x_` and `_x`*\n    - e.q. `x_capitalize_x(\u0026str) -\u003e \u0026str`, `x_add_x(n: Number, n2: Number) -\u003e Number`\n  - If the function accept multiple types, the helper functions will only choose one type to implement\n    - e.q. `_.toString([1,2])`, `_.toString(123)` =\u003e `::x_to_string(v: \u0026str) -\u003e Value`\n- About the test cases:\n  - `Examples:` section should be exactly same as the examples in lodash doc.\n  - More test cases should all be put in the `More examples` section, we relied on powerful rust's doc test\n\n## Dev memo\n\n```bash\n# Up\n./dev.sh\n\n# Watch and test single file\n./dev.sh --doc set\n\n# Lint\n./lint.sh\n\n# Preview doc\ncargo doc --open\n\n# Bump patch version and push\n./bump_push.sh\n```\n\n\u003e Check lodash.js api\n\n```console\n$ npm i\n$ node\nWelcome to Node.js v15.14.0.\nType \".help\" for more information.\n\u003e const l = require('lodash')\nundefined\n\u003e l.toString()\n''\n\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fup9cloud%2Fserde_json_lodash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fup9cloud%2Fserde_json_lodash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fup9cloud%2Fserde_json_lodash/lists"}