question

Dale Strickler avatar image
Dale Strickler asked

JSon Parsing issues!

I am trying to get a game up-to-date with all the latest SDKs. I started by bringing it up to Unity 2017 - there are a lot of Unity 2018 issues that I am not sure I should take on for this release.

I then updated the PlayFab SDK using the "update" button in the editor extensions. I got several file missing errors that I canceled. It all seems to work with minimal test time. There is a warning on this statement:

stringserverVersionValue=PlayFab.Json.JsonWrapper.SerializeObject(result.FunctionResult);

The warning it generates;

Assets/Scripts/Managers/PlayFabManager.cs(1023,56): warning CS0618: `PlayFab.Json.JsonWrapper' is obsolete: `This class is deprecated, please use PlayFab.PluginManager.GetPlugin(..) instead.'

I have read a lot about JSon parsing in Playfab specifically:

https://community.playfab.com/questions/13025/json-serialization.html

https://community.playfab.com/questions/736/209040958-SimpleJson.html

Looking at the source there is a SimpleJSon.cs file in the PlayFab SDK install. It is uses the SimpleJSON namespace.

I have tried lots of syntactic experiments and I cannot get anything like the example:

string json = PlayFab.SimpleJson.SerializeObject(yourObj);

to compile.

This statement:

stringjsonserverVersionValue=PlayFab.SimpleJson.SerializeObject(result.FunctionResult);

Generates the error:

/Users/dale/Documents/JAC/KK-app-min-iMac/Assets/Scripts/Managers/PlayFabManager.cs(41,41): Error CS0234: The type or namespace name 'SimpleJson' does not exist in the namespace 'PlayFab' (are you missing an assembly reference?) (CS0234) (KK-app-min-iMac)

I have tried different "using" combinations.

Then went back in the repo. Hand removed all things PlayFab. Reinstalled that latest UnityPF SDK and no luck. Same issues still. What am I doing wrong? For "simple" JSON it is not come very close so far. :-)

unity3d
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Andy avatar image
Andy answered

Sorry for the confusion. We marked the JSONWrapper as obsolete but have put up much documentation about how to use the new Plugin Manager. There's a bit in the repo here:

https://github.com/PlayFab/UnitySDK/blob/master/PluginManager.md

We definitely aren't forcing anyone to move over to the plugin manager, but if you want to clear all the warnings you can try replacing instances of JSONWrapper with this instead:

PlayFab.PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer)

I'd recommend just getting the plugin once and then reusing it everywhere you need it.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dale Strickler avatar image Dale Strickler commented ·

Is SimpleJSon dead? Though the source file still seems to be there. I given time line constraints I think i will just leave it with JSONWrapper unless you see that being killed sometime soon, which it seems like you are not.

0 Likes 0 ·
Andy avatar image Andy ♦♦ Dale Strickler commented ·

It's not dead. We still use it as our JSON serializer. We just don't expose it in such a way that users can reasonably access it. JSONWrapper should be fine for now. I've heard nothing about any plans to kill it. When you get a chance, I would recommend looking at how to utilize the PluginManager class properly.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.