Skip to content

Commit 710b592

Browse files
committed
Misc
1 parent ab9b92e commit 710b592

12 files changed

Lines changed: 1164 additions & 1087 deletions

File tree

Assets/Logo.ai

Lines changed: 1075 additions & 1039 deletions
Large diffs are not rendered by default.

Assets/Logo_32x32.png

1.22 KB
Loading

Swiftlet/Components/4_ReadJson/ReadJsonArray.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,22 @@ protected override void SolveInstance(IGH_DataAccess DA)
4949
JTokenGoo goo = null;
5050
DA.GetData(0, ref goo);
5151

52-
JToken token = goo.Value;
53-
if (token is JArray)
52+
if (goo != null)
5453
{
55-
JArray array = token as JArray;
56-
List<JToken> tokens = new List<JToken>();
57-
foreach (var t in array) tokens.Add(t);
5854

59-
DA.SetDataList(0, tokens.Select(o => new JTokenGoo(o)));
60-
}
61-
else
62-
{
63-
throw new Exception("Input token is not an array");
55+
JToken token = goo.Value;
56+
if (token is JArray)
57+
{
58+
JArray array = token as JArray;
59+
List<JToken> tokens = new List<JToken>();
60+
foreach (var t in array) tokens.Add(t);
61+
62+
DA.SetDataList(0, tokens.Select(o => new JTokenGoo(o)));
63+
}
64+
else
65+
{
66+
throw new Exception("Input token is not an array");
67+
}
6468
}
6569

6670
}

Swiftlet/Components/4_ReadJson/ReadJsonObject.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,30 @@ protected override void SolveInstance(IGH_DataAccess DA)
5050
JTokenGoo goo = null;
5151
DA.GetData(0, ref goo);
5252

53-
List<string> keys = new List<string>();
54-
List<JTokenGoo> tokens = new List<JTokenGoo>();
53+
if (goo != null)
54+
{
5555

56-
JToken token = goo.Value;
56+
List<string> keys = new List<string>();
57+
List<JTokenGoo> tokens = new List<JTokenGoo>();
5758

58-
if (token is JObject)
59-
{
60-
JObject obj = token as JObject;
61-
keys = obj.Properties().Select(p => p.Name).ToList();
62-
foreach(string k in keys)
59+
JToken token = goo.Value;
60+
61+
if (token is JObject)
6362
{
64-
JToken value = obj.GetValue(k);
65-
tokens.Add(new JTokenGoo(value));
63+
JObject obj = token as JObject;
64+
keys = obj.Properties().Select(p => p.Name).ToList();
65+
foreach (string k in keys)
66+
{
67+
JToken value = obj.GetValue(k);
68+
tokens.Add(new JTokenGoo(value));
69+
}
70+
DA.SetDataList(0, keys);
71+
DA.SetDataList(1, tokens);
72+
}
73+
else
74+
{
75+
throw new Exception("Input is not a JObject");
6676
}
67-
DA.SetDataList(0, keys);
68-
DA.SetDataList(1, tokens);
69-
}
70-
else
71-
{
72-
throw new Exception("Input is not a JObject");
7377
}
7478
}
7579

Swiftlet/Components/4_ReadJson/ReadJsonValue.cs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager
4040
pManager.AddTextParameter("AsString", "S", "JSON Value as string", GH_ParamAccess.item);
4141
pManager.AddNumberParameter("AsNumber", "N", "JSON Value as number", GH_ParamAccess.item);
4242
pManager.AddBooleanParameter("AsBool", "B", "JSON Value as boolean", GH_ParamAccess.item);
43-
pManager.AddParameter(new JTokenParam(), "AsObject", "JO", "JSON Value as JObject", GH_ParamAccess.item);
44-
pManager.AddParameter(new JArrayParam(), "AsArray", "JA", "JSON Value as JArray", GH_ParamAccess.item);
4543
}
4644

4745
/// <summary>
@@ -53,26 +51,17 @@ protected override void SolveInstance(IGH_DataAccess DA)
5351
JTokenGoo goo = null;
5452
DA.GetData(0, ref goo);
5553

56-
57-
JToken input_token = goo.Value;
58-
59-
try { DA.SetData(0, input_token.ToString()); }
60-
catch { }
61-
try { DA.SetData(1, input_token.ToObject<double>()); }
62-
catch { }
63-
try { DA.SetData(2, input_token.ToObject<bool>()); }
64-
catch { }
65-
66-
if (input_token is JObject)
54+
if (goo != null)
6755
{
68-
DA.SetData(3, new JTokenGoo(input_token));
69-
}
70-
if (input_token is JArray)
71-
{
72-
DA.SetData(4, new JArrayGoo(input_token as JArray));
73-
}
56+
JToken input_token = goo.Value;
7457

75-
58+
try { DA.SetData(0, input_token.ToString()); }
59+
catch { }
60+
try { DA.SetData(1, input_token.ToObject<double>()); }
61+
catch { }
62+
try { DA.SetData(2, input_token.ToObject<bool>()); }
63+
catch { }
64+
}
7665
}
7766

7867
/// <summary>

Swiftlet/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.0.1.0")]
36-
[assembly: AssemblyFileVersion("0.0.1.0")]
35+
[assembly: AssemblyVersion("0.1.0.0")]
36+
[assembly: AssemblyFileVersion("0.1.0.0")]

Yak/dist-0.1.0/Swiftlet.gha

72.5 KB
Binary file not shown.

Yak/dist-0.1.0/manifest.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: swiftlet
2+
version: 0.1.0
3+
authors:
4+
- Sergey Pigach
5+
description: >
6+
Swiftlet is a tool that lets you call into Web APIs directly from Grasshopper.
7+
If you are interested in scraping the internet, tapping into public and private
8+
APIs or testing your own web backends, Swiftlet is a tool for you! It provides a
9+
streamlined workflow for sending GET, POST, DELETE, PUT and PATCH requests to
10+
any API endpoint. It gives you advanced control over request headers,
11+
query params, supports several kinds of web authentication and lets you parse
12+
JSON formatted web responses.
13+
keywords:
14+
- web
15+
- api
16+
- get
17+
- post
18+
- request
19+
- scraping
20+
- endpoint
21+
- headers
22+
icon_url: "https://swiftlet.s3.us-east-2.amazonaws.com/Logo_32x32.png"
68.4 KB
Binary file not shown.
68.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)