playMaker

Author Topic: Json HashTable actions  (Read 3620 times)

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Json HashTable actions
« on: January 07, 2016, 05:10:34 PM »
Simple Json <> HashTable actions:

- HashTableToJson
- HashTableAddFromJson
+ ExtractFromJson

To build HashTable from Json string quickly and vice versa.

Note
Does not require DataMaker. They are independent actions.
It is built for very simple Json string (meaning Level 0 only). Anything complex (objects, arrays, lists, etc) then use DataMaker.

on ecosystem and https://snipt.net/dudebxl/

Any problems, post here
« Last Edit: January 14, 2016, 02:02:55 PM by dudebxl »

mdotstrange

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: Json HashTable actions
« Reply #1 on: January 07, 2016, 10:51:32 PM »
Awesome! Thanks!  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15373
  • Official Playmaker Support
    • View Profile
Re: Json HashTable actions
« Reply #2 on: January 12, 2016, 11:28:20 PM »
Hi,

 Very nice!

 Bye,

 Jean

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: Json HashTable actions
« Reply #3 on: January 14, 2016, 02:01:04 PM »
*** Update bump - added "ExtractFromJson" action which extracts 1 value based on key search.

rik

  • Full Member
  • ***
  • Posts: 246
    • View Profile
Re: Json HashTable actions
« Reply #4 on: January 15, 2016, 07:52:04 AM »
thanks

KellyRay

  • Full Member
  • ***
  • Posts: 170
    • View Profile
Re: Json HashTable actions
« Reply #5 on: March 03, 2016, 12:28:10 PM »
@dudebxl

Awesome action. Thanks for this.

I'm curious, could you elaborate on the ExtractFromJson action? I'm attempting to pass the yelp api into unity. I've gotten this far with your action:



But I need to drill down into the businesses list to find the names property.

Any thoughts?
« Last Edit: March 03, 2016, 12:35:00 PM by KellyRay »

dudebxl

  • Hero Member
  • *****
  • Posts: 602
    • View Profile
Re: Json HashTable actions
« Reply #6 on: March 03, 2016, 01:50:26 PM »
@KellyRay

Simple solution, don't use the action.. The yelp Json is too complicated for the action.  The moment the json has an array, list, etc, it will not work and what you seeing is that the yelp Json has an object (a list).

The actions I built is for very simple json (that you want to save, or send to a server, etc). For anything more complex, then you have to use Datamaker (on ecosystem).

Edit: See intro text if this happens to anybody else.
« Last Edit: March 04, 2016, 07:39:39 AM by dudebxl »

KellyRay

  • Full Member
  • ***
  • Posts: 170
    • View Profile
Re: Json HashTable actions
« Reply #7 on: March 03, 2016, 01:51:35 PM »
Thanks for the quick reply. I'll dive in to datamaker then.

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Re: Json HashTable actions
« Reply #8 on: April 22, 2020, 07:12:42 PM »
I've found this action on the ecosystem
https://github.com/PlayMakerEcosystem/PlayMakerCustomActions_Misc/blob/master/Assets/PlayMaker%20Custom%20Actions/HashTable/ExtractFromJson.cs

and ran into an issue where the data I want, is behind a nested array. For the curious, the URL is https://api.github.com/repos/getredash/redash/issues/3495 and when I try to use the action "Extract from Json" with extracting "user", i get the following as a result:  System.Collections.Generic.Dictionary`2[System.String,System.Object]

which should provide something like
Quote
    "login": "rauchy",
    "id": 289488,
    "node_id": "MDQ6VXNlcjI4OTQ4OA==",
    "avatar_url": "https://avatars2.githubusercontent.com/u/289488?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/rauchy",
    "html_url": "https://github.com/rauchy",
    "followers_url": "https://api.github.com/users/rauchy/followers",
    "following_url": "https://api.github.com/users/rauchy/following{/other_user}",
    "gists_url": "https://api.github.com/users/rauchy/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/rauchy/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/rauchy/subscriptions",
    "organizations_url": "https://api.github.com/users/rauchy/orgs",
    "repos_url": "https://api.github.com/users/rauchy/repos",
    "events_url": "https://api.github.com/users/rauchy/events{/privacy}",
    "received_events_url": "https://api.github.com/users/rauchy/received_events",
    "type": "User",
    "site_admin": false


 The recommendation is to convert the pulled data to something that datamaker uses, which after looking further on the forums is "Convert Json String To XML Node" but that does not seem to be included on the ecosystem's "Data Maker_XML_JSON" package.  Looks like ConvertXmlNodeToJson.cs is also missing.  Can we get those actions added please?
« Last Edit: April 22, 2020, 07:21:51 PM by PlaymakerNOOB »

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
    • View Profile
Re: Json HashTable actions
« Reply #9 on: April 23, 2020, 12:07:55 PM »
While exceptionally hacky, I was able to use the action String Split.  Added the raw json as input, and then exported to an array.  This made everything easy to find.  I was able to use "Array Contains" and search for

"login":

which provided me the index of it.  Then I just added 1 to that index, which gave me  the key I was looking for.  Problem solved!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15373
  • Official Playmaker Support
    • View Profile
Re: Json HashTable actions
« Reply #10 on: April 27, 2020, 11:55:32 PM »
Hi,

 it seems all there.



Bye,

 Jean