> ## Documentation Index
> Fetch the complete documentation index at: https://new.docs.falkordb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# json.fromJsonMap

> Parses a JSON string and returns it as a map, returning an empty map on parse errors.

## Description

Parses a JSON string and returns it as a map (object). Safely handles malformed JSON by returning an empty map on parse errors.

## Syntax

```cypher theme={null}
flex.json.fromJsonMap(jsonString)
```

## Parameters

| Parameter    | Type   | Required | Description                          |
| ------------ | ------ | -------- | ------------------------------------ |
| `jsonString` | string | Yes      | A JSON string representing an object |

## Returns

**Type:** map (object)

A map parsed from the JSON string. Returns an empty map `{}` if parsing fails or if the input is not a valid JSON object.

## Examples

### Example 1: Basic JSON Parsing

```cypher theme={null}
WITH '{"name":"Alice","age":30,"active":true}' AS json
RETURN flex.json.fromJsonMap(json) AS user
```

**Output:**

```text theme={null}
user
-------------------------------
{name: 'Alice', age: 30, active: true}
```

### Example 2: Parsing Stored JSON Properties

```cypher theme={null}
MATCH (n:Node)
WHERE n.jsonData IS NOT NULL
WITH n, flex.json.fromJsonMap(n.jsonData) AS parsed
RETURN n.id, parsed.field1, parsed.field2
```

### Example 3: Processing API Responses

```cypher theme={null}
WITH '{"id":123,"email":"user@example.com","role":"admin"}' AS apiResponse
WITH flex.json.fromJsonMap(apiResponse) AS data
CREATE (u:User {id: data.id, email: data.email, role: data.role})
```

### Example 4: Handling Malformed JSON

```cypher theme={null}
WITH '{invalid json}' AS badJson
RETURN flex.json.fromJsonMap(badJson) AS result
```

**Output:**

```text theme={null}
result
------
{}
```

(Returns empty map for invalid JSON)

## Notes

* Returns empty map `{}` if input is not valid JSON
* Returns empty map if the JSON represents a non-object value (e.g., array, string)
* Safe to use without error handling as it won't throw exceptions
* Useful for parsing configuration, API responses, or stored JSON data

## See Also

* [json.fromJsonList](/udfs/flex/json/fromJsonList) - Parse JSON string to list
* [json.toJson](/udfs/flex/json/toJson) - Serialize value to JSON string

## Frequently Asked Questions

<AccordionGroup>
  <Accordion title="What does flex.json.fromJsonMap return for invalid JSON?">
    It safely returns an empty map `{}` without throwing an exception, making it safe to use without error handling.
  </Accordion>

  <Accordion title="Can I access nested properties from the parsed map?">
    Yes. Once parsed, you can use dot notation to access nested properties, e.g., `parsed.field1`.
  </Accordion>
</AccordionGroup>
