# There is a bug in the Json library in UE

**URL:** <https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, json, question\
**Created:** [April 20, 2023, 12:05pm UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511 "2023-04-20T12:05:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![goodriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@goodriver](https://forums.unrealengine.com/u/goodriver)\
**Post date:** [April 20, 2023, 12:05pm UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511/1 "2023-04-20T12:05:59Z")

</div>

1. Parsing float within JSON in C++yields values that do not match the data  

2. In the blueprint, the data obtained and sent using the blueprint plugin[Json Blueprint Utilities] is incorrect

---

<div class="post-metadata">

**Author:** ![pladux](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pladux/32/1194519_2.png) [@pladux](https://forums.unrealengine.com/u/pladux)\
**Post date:** [April 20, 2023, 11:29pm UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511/2 "2023-04-20T23:29:21Z")

</div>

That’s not a bug. It’s a floating point issue. [https://floating-point-gui.de/](https://floating-point-gui.de/)

---

<div class="post-metadata">

**Author:** ![goodriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@goodriver](https://forums.unrealengine.com/u/goodriver)\
**Post date:** [April 21, 2023, 2:29pm UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511/3 "2023-04-21T14:29:06Z")

</div>

But this plugin does not read the float correctly

---

<div class="post-metadata">

**Author:** ![pladux](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pladux/32/1194519_2.png) [@pladux](https://forums.unrealengine.com/u/pladux)\
**Post date:** [April 21, 2023, 5:14pm UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511/4 "2023-04-21T17:14:45Z")

</div>

What do you mean?

---

<div class="post-metadata">

**Author:** ![goodriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@goodriver](https://forums.unrealengine.com/u/goodriver)\
**Post date:** [April 23, 2023, 2:18am UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511/5 "2023-04-23T02:18:28Z")

</div>

In JS language, you can correctly obtain number

Extracting Float from Json using UE’s library still has some deviations

The best way is to extract String from Json

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/3/1/53144289ee3719dfbe30b4288bab3abb37bc2478.png)

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [April 24, 2023, 2:45pm UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511/6 "2023-04-24T14:45:41Z")

</div>

This is normal C++ behavior.

The small deviation shouldn’t have any impact most of the time, but it’s something to be aware of. In most UE functions dealing with float/double, there is a Tolerance parameter (with a sensible default value) to mitigate the deviation, for example in FVector comparisons :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/9/61928bbf508ed229437000567c5a97db08b5b065.png)

If you are comparing floats/doubles directly you should also take that into account :

```cpp
float A = 0.1f + 0.3f;

// Don't do this
if (A == 0.4f)
{
    //...
}

// Do this instead
if (FMath::IsNearlyEqual(A, 0.4f))
{
    //...
}

// Or this
if (FMath::Abs(A-0.4f) <= UE_KINDA_SMALL_NUMBER)
{
    //...
}

```

When it comes to displaying floats and doubles to screen, use a format to automatically handle rounding to the amount of decimals you need. Having a deviation at the 10th decimal isn’t gonna impact the number you display with 2-3 decimals.

---

<div class="post-metadata">

**Author:** ![goodriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@goodriver](https://forums.unrealengine.com/u/goodriver)\
**Post date:** [September 11, 2023, 7:56am UTC](https://forums.unrealengine.com/t/there-is-a-bug-in-the-json-library-in-ue/1134511/7 "2023-09-11T07:56:50Z")

</div>

Have the bugs been fixed?
