EasyJsonParser

I have released EasyJsonParser as my third self-made UE4 plugin.

EasyJsonParser: ayumax: Code Plugins - UE4 Marketplace

This shares the same concept as the second plugin, EasyXMLParser, allowing you to retrieve values within Json using a simple access method from Blueprints.

I have also uploaded a sample project to GitHub, so please refer to it if you are interested.

How to Use

After loading a Json string or Json file, retrieve values by specifying an access string.

Specifying Access Strings

Basically, specify the path to the desired value by connecting elements with dots.

Simple Case

To get the value of “prop” from the simple Json below, the access string is prop.

{
  "prop":"abc"
}

Hierarchical Objects

If it is hierarchical like below, create the access string by connecting with dots.

In the case below, to retrieve the prop property within the obj object, the access string is obj.prop.

{
  "obj":
  {
    "prop":"abc"
  }
}

Including Arrays

If it is an array like below, specify which element you want to retrieve.

For example, to get the second prop, it would be obj[1].prop.

To get the first prop, it would be obj[0].prop.

{
  "obj":[
  {
    "prop":"abc"
  },
  {
    "prop":"def"
  }
  ]
}

Getting Values by Specifying Type

The following four functions are provided for getting values from Json.

  • ReadInt(int)
  • ReadFloat(float)
  • ReadString(string)
  • ReadBool(bool)

Enter the access string in “AccessString”.

Enter the default value in “DefaultValue”. If the specified value does not exist in the Json, the default value is returned.

Getting Objects

There are also “ReadObject” and “ReadObjects” methods to get elements as objects rather than values.

Only object properties can be retrieved with these methods.

ReadObject gets a single node object.

ReadObjects gets an array of multiple objects.

You can also use it as shown below, by first getting an object from an intermediate hierarchy level, and then getting properties of that object.

What Can Be Done Now and Future Plans

This time, I focused solely on implementing the function getting values from Json as simply as possible.

Currently, Json is used in various places, such as saving config values in configuration files and exchanging data via Web APIs.

Using this plugin makes it easy to extract values from such Json using Blueprints.

I am considering the following as candidates for future feature enhancements. Especially since only value retrieval is possible now, I think adding the ability to set values would broaden its scope.

  • Multi-platform support
  • Setting values