KonfuPanda
KonfuPanda

Reputation: 243

Adding Json.Net to a Unity3D project

I added the Json.Net library to Visual Studio 2013 via NuGetpackage and installed it for NetFramework 4.5. I don't get an error in Visual Studio when I add

using Newtonsoft.Json;

but in Unity3D 5.0 I get the error:

Assets/RobotController.cs(5,7): error CS0246: The type or namespace name `Newtonsoft' could not be found. Are you missing a using directive or an assembly reference?

I looked up in my packages folders for this project and the dll file is there, so I don't understand the problem. Thx for help.

Upvotes: 18

Views: 49249

Answers (8)

Applejag
Applejag

Reputation: 1248

For support in built versions, recommended to use one of following

Or if you dont require Newtonsoft.Json (Json.NET), here's some other alternatives (all works in Unity, I've omitted libraries that don't, and there's a lot of 'em):

There is quite the table of candy to select from. Choose well young padawan~

Upvotes: 6

Rafe
Rafe

Reputation: 429

You can simply use Asset Store to add the fabulous newtonsoft.JSON library named JSON .NET For Unity at the Store.

https://assetstore.unity.com/packages/tools/input-management/json-net-for-unity-11347

Upvotes: 4

user2308078
user2308078

Reputation: 1

If you adding reference to *.dll through IDE and after recompile IDE throws out, check if you have assembly definition. If so, you need to add it to Assembly References. It worked for me. Inspector

Upvotes: 0

rluks
rluks

Reputation: 2862

I have stumbled upon this project https://github.com/SaladLab/Json.Net.Unity3D

Newtonsoft Json.NET is a de facto standard JSON library in .NET ecosystem. But it doesn't support Unity3D, so it's a little bit hard to use JSON.NET just after getting Json.NET package. This package is for Unity3D programmers that need to use latest Json.NET in Unity3D.

Just import the unity package and you are good to go.

Upvotes: 4

KollKode
KollKode

Reputation: 433

I had just the same problem in Visual Studio 2015. But Utamaru's solution worked for me.

Make a folder: Assets/Plugins where you put the *.dll file and add it as a reference.

To add a reference you highlight the Analyzers in the Solution Explorer in Visual Studio and under Project > Add Reference you can find your *.dll file located in Assets/Plugin by browsing to it.

Add reference in Visual Studio 2015 part 1 Add reference in Visual Studio 2015 part 2

Upvotes: 19

philont
philont

Reputation: 130

Use simpleJson. Its free and gets the work done.

Copy the SimpleJSON.cs contents into a newly created file in your project and you're ready to go. If you want to be fancy -> create this new file in assets\plugins directory

http://wiki.unity3d.com/index.php/SimpleJSON

Upvotes: 1

Atra Viator
Atra Viator

Reputation: 535

JSON.NET for Unity3D is available on the asset store; https://www.assetstore.unity3d.com/en/#!/content/11347

Upvotes: 1

aydjay
aydjay

Reputation: 868

You need to add the dll to your projects references.

References >> Add Reference.

Upvotes: -5

Related Questions