# JSON.stringfy breaking change Vector3

**URL:** <https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210>\
**Category:** Questions\
**Created:** [September 16, 2020, 12:24am UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210 "2020-09-16T00:24:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)\
**Post date:** [September 16, 2020, 12:24am UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/1 "2020-09-16T00:24:16Z")

</div>

I was checking out the beta to see if my current app would need to be modified. I noticed one thing that was broken. In 4.1, `JSON.stringify(<vector3>)` would return `{"x":0,"y":12,"z":32}` however in the latest build it returns `{"_isDirty":true,"_x":0,"_y":12,"_z":32}`

[Here is a playground](https://www.babylonjs-playground.com/#6214R1) so you don’t have to type it out.

Will this be the version going forward?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [September 16, 2020, 8:35am UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/2 "2020-09-16T08:35:55Z")

</div>

Yes, I think this change has been done to improve performances of Vector3 in some circonstances.

@Deltakosh will know better.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [September 16, 2020, 3:00pm UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/3 "2020-09-16T15:00:18Z")

</div>

> [@Devin\_Wright](#):
>
> would return

We did that to be able to cache vector3 value so yes this is the going forward state 😉

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [September 16, 2020, 4:08pm UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/5 "2020-09-16T16:08:56Z")

</div>

There is always Vector3.toString() but I dont know if that helps you.

---

<div class="post-metadata">

**Author:** ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)\
**Post date:** [September 16, 2020, 4:39pm UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/6 "2020-09-16T16:39:46Z")

</div>

It’s no problem, I just had to change how I read the value back in to use `_x` instead of `x`, it was just an unexpected issue when updating.

Thanks!

---

<div class="post-metadata">

**Author:** ![aWeirdo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/aweirdo/32/52_2.png) [@aWeirdo](https://forum.babylonjs.com/u/aWeirdo)\
**Post date:** [September 16, 2020, 4:45pm UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/7 "2020-09-16T16:45:09Z")

</div>

i would always use an array in such cases, [xVal , yVal , zVal] will never change 🙂

---

<div class="post-metadata">

**Author:** ![Devin\_Wright](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/devin_wright/32/4302_2.png) [@Devin\_Wright](https://forum.babylonjs.com/u/Devin_Wright)\
**Post date:** [September 16, 2020, 4:46pm UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/8 "2020-09-16T16:46:30Z")

</div>

Yea, that’d be the best bet, to just serialize it myself as some interface, but since it just worked as is in the past, I left it alone.

---

<div class="post-metadata">

**Author:** ![Lemcat](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lemcat/32/44469_2.png) [@Lemcat](https://forum.babylonjs.com/u/Lemcat)\
**Post date:** [January 28, 2025, 6:43am UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/9 "2025-01-28T06:43:58Z")

</div>

I’m just stuck with the same problem. It’s very uncomfortable when you do serialization and back. While Vector3/Quaternion converts to a string like this:

```typescript
"position": {"_isDirty":false,"_x":2,"_y":0,"_z":0},
"rotation": { "_isDirty":false,"_x":0.7071067811865475,"_y":0,"_z":0,"_w":0.7071067811865476},
"scale":{"_isDirty":false,"_x":1.0546875,"_y":1.0546875,"_z":0.1 }

```

it’s very uncomfortable when you get such structure after simlpy calling `JSON.stringify()`. When you store such data in JSON files there is some overhead. So seems I will simply replace replace strings:

```typescript
'"_isDirty":false,' --> "" 
'_x" ->- "x" 

```

but there will be some pain if the format of Vector3 sometime will change to same other.

---

<div class="post-metadata">

**Author:** ![Lemcat](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lemcat/32/44469_2.png) [@Lemcat](https://forum.babylonjs.com/u/Lemcat)\
**Post date:** [January 28, 2025, 6:48am UTC](https://forum.babylonjs.com/t/json-stringfy-breaking-change-vector3/14210/10 "2025-01-28T06:48:42Z")

</div>

And as far as I understand from explanation above it’s better not to redeclare `toString()` prototype for Vector3 😄
