# Util.paths Module

\
&#x20;Import

```
import { paths } from 'util';
```

### Methods

[to(object, path, value, returnSourceObject)](https://docs.medable.com/reference#section-to-object-path-value-returnsourceobject-)

### to(object, path, value, returnSourceObject)

Search `object` for a path using a dot syntax and returns a value. If the `value` argument is present, the function writes the path to the object and returns the inner most object match, creating objects when none are present.

**Arguments**

* `object` (Object) The object to search or update.
* `path` (String) The path to search or update. Sub-properties can be found/updated using a `.` as a separator.
* `value` (\*) If present, writes to the innermost path. If any of the properties are missing from the path, they are created as plain javascript objects.
* `returnSourceObject` (Boolean) If true, returns `object` instead of the innermost property.

**Returns**

*

JavaScript

```
import { paths } from 'util';

const object = {
  foo: [
    0,
    1,
    {two: 'two'}
  ]
};

paths.to(object, 'not.a.property'); // undefined
paths.to(object, 'foo.2.two'); // 'two'
paths.to({}, 'a.b.c', 'd'); // {c: 'd'}
paths.to({}, 'a.b.c', 'd', true); // {a: {b: {c: 'd'}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.medable.com/cortex-api/scripting/modules-1/util.paths-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
