For the past couple of nights, while plowing through the codebase, I’ve been working on a plugin that allows you to communicate with servers through JSON with pure Blueprint nodes! Since I figured it could be helpful to at least some of you, I’m sharing the complete package!
- Post JSON data to any URL
- Get JSON data from any URL or string
- Create your own custom post data with the Create JSON Data node
- Get and set object/string/int/float/null (array) values in the post data, by key
GitHub (included binaries for 4.21) UPDATED 19/11/2018
- Overall method cleanup
- 4.21 API adjustments
- Fixed array case where key was being used while it was empty
- Added proper credits to everyone at the top of the source files and the Github page
- Added an event broadcaster for when the request fails for any reason (cheers Kheka!)
- Compiled with UE4.7.6
- Added header Content Type “application/json” for mobile/Android support (thanks Zakkar!)
- Added node for getting all keys from the data (thanks johnbo!)
- Added a “From String” node, so you can load JSON data from a string, instead of being forced to use URLs (cheers conneich!)
- Updated the plugin to UE4.7.3
- Changed the version number to 0.8
- Built the plugin with the correct version info so it will actually boot from the launcher build (thanks again Patrik2991! )
- Updated the plugin to UE4.7.2
- Updated the plugin to the 4.6 release branch
- Updated the plugin to UE4.6
- Updated the plugin version to 0.7
- Changed the plugin type from Developer to Runtime so it will also run in packaged games
- Added array support for both string and field data
- Refactored some of the code
- Created a proper icon for the plugin
- Made most of the functions pure, so it doesn’t require as many intermediate variables
- Updated plugin to UE4.5 (sorry for the delay!)
- Fixed a bug by prefixing the input URL with http:// when needed (it crashed the editor)
- Fixed crash when trying to load a URL with invalid JSON data
*NOTE: If you can’t see the JSON category or nodes, be sure to turn off “Context Sensitive”
If you guys have any comments, feature requests or improvements, please don’t hesitate to ask.
Lastly, I just want to give a shoutout to Rama for being a big help with his tutorials, if you’re reading this, cheers buddy, you’re awesome!
Seems like a great plugin! While I don’t have any use for it now, I definitely see potential for the future.
Oh yeah. That’s fantastic. I am so happy with the UE4 community being so generous with their code. This is exactly what I needed to prove a concept Cheers!
I can definitely see use for this, well done Stefan! netjes
Correctly I’m doing? - http://i.imgur.com/Pg1d9Yl.png
It return - void
Denny: Cheers, thanks for the reply!
Tom: Cheers bro, your support is greatly appreciated, let me know if you need any help!
iMuse: Thanks man, graag gedaan!
ga2mer: Actually, you almost got it! You need to assign the return post data value to a variable and then bind to the event, the Get Data By Key node doesn’t do anything until you fill it with data So basically you’re missing a few nodes, in order to request on button press, you’ll have set it up like this (without any validation):
Sorry for the confusion, let me know if that helps, I’ll add this example to my first post as well!
very sweet plugin! I really can’t wait for the marketplace and many of these little plugins are incorporated.
Its one of those things i would much prefer to prototype in blueprints and then go back and rewrite important things in C++. But even something like this, assuming its not time critical/looping multiple times i wouldn’t even rewrite it! (say for just pulling update news or something like that).
One note though - You shouldn’t need the Intermediate directory in your rar. By including the source those libraries and such are generated when building your plugin into a given project.
KRushin: Cheers man, if you stumble across any issues be sure to let me know! At my current company we mainly use JSON to communicate with our servers, so I figured it’d make sense to start my Unreal 4 journey with this little plugin!
Bob: Thanks for the feedback man, I’ve removed the folder… Should I add the plugin to the Wiki as well so it’s a little more visible to the new users? Not sure what the policy is on that
I’m planning to integrate nested keys as well in a few days, as well as XML support, to make it a little more flexible!
Please do. The wiki is open to all contributions, but you should be willing to allow others to modify it =)
Keep up the good work!
wow all these cool plugins around the forum… saving me a lot of work thanks Stefander
Bob: No worries, I’d love that! I’ll put it up later today, cheers!
Xces: Glad you like it, it’s my very first contribution!
I’m very grateful for all these kind comments, thanks everyone, I’ll be releasing more stuff soon!
one quick question: does it works with JSONArrays ? if yes how ?
And how safe is it against hacking?
Will we see this updated for 4.2.1? It says it’s not compatible?
This looks great - i’m pretty rubbish at the visual studio side -I can’t get it to recompile for 4.2.1. Would I be able to point this at a local python JSON server rather than an URL? I’ve been looking for a way to drive Unreal through a UDP or something but I know i won’t be able to get my head around the visual studio stuff. If I can send and receive through a local JSON that would probably do what I need it to do. Cheers (could you recompile for us dummies?)
Absolutely yes if your local server is a http server And no, if your server is not http server and works with your own protocol. In case of socket server, you should use this approach.
I can’t get it to work with Unreal Engine 4.2.1… Any help is highly appreciated!
When I put the plugin in “GameFolder/Plugins/JSONQuery” and I start up my project it says: „Project modules are missing or out of date. Would you like to recompile them?"
If I click Yes the compilation fails…
Oh, I’m on Mac OS X, so maybe this is an issue…?!
When I start my project with 4.1.2 the following error appears:
“Plugin ‘JSONQuery’ failed to load because module ‘JSONQuery’ could not be found. This plugin’s functinality will not be available. Please ensure the plugin is properly installes, otherwise consider disabling the plugin for this project.”
Plugin is placed in UnrealEngine/4.1/Engine/Plugins/JSONQuery
Sorry for the late reply guys, it’s been crazy busy!
@Xces: It doesn’t currently, but nice idea, if I have some spare time soon I’ll see what I can do! Cheers!
@orgertot: Well, it does exactly what it says right now, I didn’t explicitly check the input and/or strings for any suspicious activity (but I might add it in a future release if there are any real threats)! All it does is expose this functionality to blueprints, which was the original intent of the plugin
@Darkkitten and thomasaull: The binaries in the OP are compiled for 4.1, but I’ve just recompiled and overwrote the download link in the original post for 4.2. I’m at the office right now and I don’t have the latest engine version, but this one should work fine! But if you guys still have any problems, let me know!
Also thomasaull, I’ve provided the binaries for Win64, but not OSX, so you’ll need to compile them yourself unfortunately (I don’t have a Mac at my disposal)…
I’ve tried to use this exactly as you’ve specified in the ‘request page on button’ example, but it just crashes the editor. I’m using a local python JSON server which seems to work fine using a python client. Any ideas there?