# apoc.convert.setJsonProperty

**URL:** <https://community.neo4j.com/t/apoc-convert-setjsonproperty/66237>\
**Category:** Procedures & APOC\
**Tags:** apoc, json\
**Created:** [February 9, 2024, 8:32am UTC](https://community.neo4j.com/t/apoc-convert-setjsonproperty/66237 "2024-02-09T08:32:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![joshcornejo](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/joshcornejo/32/34171_2.png) [@joshcornejo](https://community.neo4j.com/u/joshcornejo)\
**Post date:** [February 9, 2024, 8:32am UTC](https://community.neo4j.com/t/apoc-convert-setjsonproperty/66237/1 "2024-02-09T08:32:30Z")

</div>

Hi,

**Note** : I don't foresee doing anything with the JSON inserted within Neo4J, it could be considered a very long string, and the semantics are required at the application layer.

I am building a set of API and some of my 'work' so far has been synthetic - especially the JSON I was inserting in a field (body). Anyway, so far I had this:

```auto
CREATE (a:Node { 
    name: 'short name', 
    description: 'long description',
    body: '{it was a simple placeholder JSON body}'
  } ) 
  WITH a MATCH (p:DiffLabel) WHERE elementId(p) = 'a'    
    CREATE (p)-[:hasrel]->(a) 
  WITH a MATCH (t:AnotherLabel {qualifier:'qual'}) 
    CREATE (a)<-[:type]-(t) 
 RETURN elementId(a) as newIdentifier

```

it was working fine, but now I am inserting actual JSON into the field:

```auto
CREATE (a:Node { 
    name: 'short name', 
    description: 'long description',
  } ) 
  WITH a MATCH (p:DiffLabel) WHERE elementId(p) = 'a'    
    CREATE (p)-[:hasrel]->(a) 
  WITH a MATCH (t:AnotherLabel {qualifier:'qual'}) 
    CREATE (a)<-[:type]-(t) 
  WITH a CALL apoc.convert.setJsonProperty(a, 'body', {REAL JSON})
 RETURN elementId(a) as newIdentifier

```

The code now creates the node a, but doesn't create the relationships and doesn't return the newIdentifier variable.

I have tried different orders for the apoc procedure (after the create, and now after that matches).

Ideally, I want to keep it all as a single statement (so i don't have to work with transactions)

---

<div class="post-metadata">

**Author:** ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)\
**Post date:** [February 9, 2024, 4:26pm UTC](https://community.neo4j.com/t/apoc-convert-setjsonproperty/66237/2 "2024-02-09T16:26:06Z")

</div>

It worked for me, once I ensured the elementId of 'p' was valid.

 ![Screen Shot 2024-02-09 at 11.20.20 AM](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/b/d/bd5a4ecdfbd1b49fe02bdb1fd8c4c9946d9a3387.png)

BTW- the way I see this procedure working is to take a complex neo4j map and convert it to json format as a string. This means surrounding the keys with escaped double quotes and the whole thing in double quotes (so it is a string).
