Hello everyone,
I’m playing around with some game mechanics which include the need to have a json file attached to an item ( it sounds weird but yeah this is how it works)
So, I’m trying to have some fields saved as a JSON file and then upload it to a server, the reason I need to do that is that these json files will be unique named for each game Item, so I can’t just post changes to an already json file.
So I need to have the file name jsonItemName#1.json and uploaded like that on my server.
would appreciate any help,
Thank you!
So waht is the Problem? Saving the json (which is usually a text file) or uploading to a Server? If uploading to a Server, why mess around with file names?
both, I don’t know how to save it to the .json file and then how to upload it to the server. The reason I need to mess with filenames is that I need every .json to have a unique name because it needs to be attached to the item after that.
I know it sounds weird but this is how the system works, unique filename.json from server
Not to put too fine a Point on this, but whenever I hear people telling me ‘it sounds weird, but’ I hear them say ‘I don’t know why’. Do you at least know what kind of Server you are uploading to? And to be blunt: saving files and uploading them is easily Google-able as there is example code in Unity’s documentation. Have you tried that? Here’s how to upload a file.
Yes it will be uploaded to my dedicated server and after that, I know what I’ll do with it (I then just need the //servername/filename.json), ok nice info on the upload a file, how about the saving to .json with a custom name (taking from a variable) and do this on runtime?
Google ‘Unity write text file’
You know how to Google, don’t you?
thanks for your answer, I guess forums are not needed then 
The reason I created this topic is to start a conversation about this issue I have and maybe get answers that might help others later and have combined information about this which I haven’t found when I googled, as to how to have .json files created in RUNTIME (important) and then uploaded to your server with custom names etc.
If anyone has any other answer I would appreciate it.
It’s a matter of politeness to at least do some of the obvious research before asking other to do that for you. If I Google ‘Unity write text file’ I get at least 6 relevant links in the top half that show how to generate text files and save to your file system at runtime. If you don’t know that json files are text files, well…
Yeah I did my research before posting, and I didn’t find my answer on the full topic I posted here, it would be polite if you could please stop going off-topic. thanks
Json created at runtime isn’t a significant distinguishing characteristic- there are no systems in Unity to create Json only in the editor. JsonUtility is quite limited, but it’s still a UnityEngine class, which means it works at runtime just as well as any other time, and you can easily find information on it in the documentation, plus Unity Learn videos that cover serialization with JsonUtility in sample projects.
If you find that the limitations of JsonUtility make it too difficult to use in your case, you can also check out Newtonsoft / Json.NET, which is what I use most heavily for my own serialization tasks and web requests. Json.NET is outside of the scope of help specifically with Unity though, unless you have errors thrown on importing the git repo or something, and it would be better to look up information specific to it through its extensive documentation and many many videos. Using it in Unity is pretty much identical to using it in any other .NET/Mono-based application software.
As for the server part, that’s also outside of the scope of the Unity discussion boards- making a web server to take and respond to requests can be done a million different ways depending on the available tools and technology, and the languages you know. If you’re fond of C#, you can check out ASP.NET Core, which is what I use in my day job, or you can use PHP on a Linux machine, you can communicate with a Google Drive account through a Google Scripts App and have files uploaded / downloaded through that, or simply store the data in a spreadsheet instead.
The sky is the limit, and all of the requests to all of these APIs will look pretty much identical from the Unity side, which is why there’s not really much more anyone here can do for you unless you narrow things down considerably. Remember that Json is just a string- so you can send it wherever you can send a string, it’s just a matter of if the server knows how to read it. If you have any really specific questions about your attempted implementation of this, along with all of the technologies that you’ve chosen, the server you use, the things you’ve tried and which don’t work, etc, then we’ll be glad to help you with that.
Thank you for your reply @DonLoquacious
Already using a php apache server using bitnami wamp to parse data for some other part of my game, now I needed something easier to just save a text .json file and upload it to the server, I guess I can implement the similar techniques I use for the parsing but reverse it to upload the file to the server without the decerialization (as I just need the whole file to upload to the server).
will play around with that and see how it goes, thanks again 