# Getting non-literal string from JSON in c++ UE4

**URL:** <https://forums.unrealengine.com/t/getting-non-literal-string-from-json-in-c-ue4/324020>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [July 4, 2015, 12:26am UTC](https://forums.unrealengine.com/t/getting-non-literal-string-from-json-in-c-ue4/324020 "2015-07-04T00:26:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MNP\_David](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MNP\_David](https://forums.unrealengine.com/u/MNP_David)\
**Post date:** [July 4, 2015, 12:26am UTC](https://forums.unrealengine.com/t/getting-non-literal-string-from-json-in-c-ue4/324020/1 "2015-07-04T00:26:48Z")

</div>

I am using the FJsonObject class to get JSON from a file I am reading. These files contain the localization for my game.

Everything seemed to go smoothly, until I realized that the getStringWithKey method that I was using was returning ANSI FStrings only. I need these to return UTF-8 FStrings so that the Chinese, Japanese, etc. languages work.

```
FString AJSONContainer::getStringWithKey(FString key)
{
	return storedJSON->GetStringField(key);
}

```

Thus far, I’ve managed to get the value as an FJsonValueObject, but I have been unable to figure out how to get the value as a std::string or a TCHAR so that I can convert it to a wide-character string.

```
FString AJSONContainer::getUnicodeStringWithKey(FString key)
{
	FJsonValueObject out = storedJSON->GetObjectField(key);

}

```

The only method I see on FJsonValueObject that is relevant is `.AsString()`, but that returns as an FString, and I can’t run FString through the `TEXT()` method.

Any ideas on how I can convert this FString to UTF-8?

---

<div class="post-metadata">

**Author:** ![Steve\_Robb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steve\_Robb](https://forums.unrealengine.com/u/Steve_Robb)\
**Post date:** [July 6, 2015, 12:12pm UTC](https://forums.unrealengine.com/t/getting-non-literal-string-from-json-in-c-ue4/324020/2 "2015-07-06T12:12:38Z")

</div>

Hi,

You can use the FTCHARToUTF8 object to convert an FString:

```
FTCHARToUTF8 ConvertedStr(*MyFString);
const UTF8CHAR* ConvertedPtr = ConvertedStr.Get();

```

ConvertedPtr is legal as long as ConvertedStr exists.

Steve
