"RbxUtility.DecodeJSON is deperecated..." when using MarketplaceService

Repro steps:

  1. Set up a developer product
  2. Set game.MarketplaceService:PromptProductPurchase()
  3. Look at local console
  4. Done

It’s not a bug.
Nothing is malfunctioning, it’s just a warning.

But it can be a little annoying when you see it spammed in the developer console if you call a purchase a lot.

All they need to do is change the RBXUtility JSON en/decode to the HTTPService’s one, so yeh I guess so, it wouldn’t take much to fix.

Fortunately they’re not accepting pull requests right now but it’s an easy change.

I’m still using RbxUtility.DecodeJSON just because I’ve heard of so many problems with HttpService’s JSONDecode.

[quote] I’m still using RbxUtility.DecodeJSON just because I’ve heard of so many problems with HttpService’s JSONDecode. [/quote]Hell yes, sometimes it bugs out for me with “keys must be strings” even though all keys are strings.

Issues with HttpService:

  1. Decided which parser to use (New short one or the old one in RBXUtil
  2. Encoding/Decoding {Table={},Value=“This”,1} will end as {1} (Issue with mixed variable tables)
  3. Can’t do tables like {102=“Block 1”,18=“Block 2”}

I use HTTP service one a lot, and never run into problems.

At this point HttpService’s JSON methods are pretty good, except they don’t allow characters in the range 128-255. For example, it will choke on this:

game:GetService("HttpService"):JSONEncode({"¬_¬"})
--> Can't convert to JSON

The examples FromLegoUniverse posted below aren’t valid JSON (e.g. {102=“Block 1”,18=“Block 2”}), so it makes since that it can’t handle them.

[quote] 2. Encoding/Decoding {Table={},Value=“This”,1} will end as {1} (Issue with mixed variable tables)
3. Can’t do tables like {102=“Block 1”,18=“Block 2”} [/quote]

Interested in what you think the correct JSON representations of these should be…

[quote]
Interested in what you think the correct JSON representations of these should be… [/quote]

I don’t believe there is a “correct” representation, but here’s an example of what could be done:

[tt]{“Table”:[],“Value”:“This”,“1”:1}[/tt]

But it’s not the job of the JSON serializer to magically guess the transformations required to turn your table into valid JSON. You should modify your table and then pass it in.

And the problem you then get is that when you decode the table, you get [tt][“1”]=1[/tt] in the result instead of [tt][1] = 1[/tt] because the decoder can’t magically tell that you wanted a numeric key.

So if you want string keys in the JSON, give it string keys in the table to encode.

[quote]
Interested in what you think the correct JSON representations of these should be… [/quote]

I don’t believe there is a “correct” representation, but here’s an example of what could be done:

[tt]{“Table”:[],“Value”:“This”,“1”:1}[/tt]

But it’s not the job of the JSON serializer to magically guess the transformations required to turn your table into valid JSON. You should modify your table and then pass it in.[/quote]This Lua library (http://regex.info/blog/lua/json) seems to do that just fine, to the point where I’m considering using it as a ModuleScript replacement for JSONEncode. Tried it in ROBLOX already and it works fine.

If that library can do it fine, no reason ROBLOX can’t.

It would be possible for HttpService:JSONEncode() to automagically coerce number keys to strings when necessary, but then users will complain about this confusing behavior (I encoded it this way, why did it change!). I suppose JSONEncode() could emit a warning whenever a table contains numeric keys to let the user know.