Deserialize only some fields from a JSON file

I’m trying to parse a very large JSON string in Unity. I do not need all the fields and I can’t create a class with all the members.

It appears that all examples I have found, including the official docs, always deserialize and map every field to class members, which I cannot do for my application.

I tried creating a class that is similar to the JSON string, meaning that it has some members of the target JSON, just not all of them. But it’s not working as desired: all members of my class are always undefined after deserializing.

Here’s part of the string:

{     "Robots":[{"CanReset":false,     "CycleTime":123.875,     "Info":null,     "LevelInfo":null,     "Name":"FTF_10033",     "State":0,"     ...     }, ... } 

So I tried creating these classes:

[Serializable] public class jsonData {     public Robot[] robots; }  [Serializable] public class Robot {     public string Name = "Unknown AGV"; } 

And printing the results:

var jsonString = www.downloadHandler.text; jsonData jsonData_ = JsonUtility.FromJson<jsonData>(jsonString); Debug.Log("Json data: " + jsonData_); Debug.Log("Robots: " + jsonData_.robots); 

jsonData_ prints Json data: jsonData_, and jsonData_.robots prints nothing (just Robots:).

Is there any way to parse just these particular fields out of the JSON string?

I would be content with something like jsonString["robots"][0]["name"] or something.

Arcane Disciple when some spells are already on spell list

Was just looking for a bit of insight into the Arcane Disciple feat. A quick quote on what that does:

Add the chosen domain’s spells to your class list of arcane spells. If you have arcane spellcasting ability from more than one class, you must pick which arcane spellcasting ability this feat applies to. Once chosen, this decision cannot be changed for that feat. You may learn these spells as normal for your class; however, you use Wisdom (rather than the normal ability for your spellcasting) when determining the save DC for the spell. In addition, you must have a Wisdom score equal to 10 + the spell’s level in order to prepare or cast a spell gained from this feat. Each day, you may prepare (or cast, if you cast spells without preparation) a maximum of one of these domains spells of each level.

I’m looking into a summoner build, and want to get into Thaumaturgist as a sorcerer. I figured I’d take Arcane Disciple and pick the summoning domain for Lesser Planar Ally. As a sorcerer though, all the Summon Monster spells and Gate are already Sor/Wiz spells. Does this mean I now need 19 WIS to cast Gate and the appropriate WIS for Summon Monster 1/2/3/5/7? Or can I still use these spells as a sorcerer and just rely on CHA for the main stat?

For further context, Vow of Poverty is part of the character build for a bit of game-balancing flavour. Just wondering if I need to allocate one of my 4 stat increases to WIS. Otherwise I’d rather put my points into just about anything else. Has anyone seen any rules regarding this? Or is it just a straight "the spells in this domain list now rely on WIS", regardless of whether or not they were already on your class list?



What are some good feats for sorcerer’s from current or any other previous versions of Dnd? [closed]

I am playing a shadar kai, Giant Soul(strom) sorcerer(level 06).
I took the crossbrow experties feat at level 1.
I have +4 mod on both Dex and Cha, and a +3 mod on Con. (I have +6 bonus on Con saves).
With haste, shield, absorb element and shadar kai’s necrotic damage resistance I fight in melee.

My my usual attack pattern is-
1.Go in mele use shocking grasp
2.haste atk-use a hand crossbow
3.bonus action-another hand crossbow atk(Through crossbow experties feat)

Why min-maxing? Because eveeryone in the party does. If I don’t I will feel useless in combat. The DM has allwed a lot of previous version material to the other players.

I have already thought of war caster, but with the defence I have conscentration is not a big problem. Also, if shocking grasp hits I can back off without provoking opportunity attack and have the 60′ movement due to haste.

With this build of mine what would be the best feat for me(any verion/any book)?

Search for range in continuous function satisfying some condition

I am attempting to define an optimization for the following problem: given two graphs find (the largest possible) areas where some condition holds.

Interesting portions are where the Red graph is above the Green one. All, or part, of such areas may satisfy the condition.

Googling for optimization algorithms, e.g. ones mentioned in Scipy’s optimization tutorial, returns results focusing on finding a single point, usually the min/max of some condition. I am having trouble finding algorithms that search for ranges.

The graphsR and G are KDEs generated with Gaussian functions. I can find the intersections of the graphs (e.g. with brentq and between each pair calculate P and S (the conditions). The blue vertical lines are the intersections; blue horizontal lines with text are shown only when the conditions were met for the whole range.

In many cases a subset of the range satisfies the condition as can be seen in black. Those are results from a ML algorithm which I want to replace with a numerical calculation.

Example 1: ML algo found better solution on the right section, neither found the left one interesting. enter image description here

Example 2: on the right you can see the ML algo suggesting a range not quite between the blue lines. I am OK with the new algo clipping the portion on the left. enter image description here Example 3: showing that there may be more than one interesting range per marked section. enter image description here Example 4: ML algo missed the leftmost range enter image description here

Does a function $f$ exists such that: $f(n-k) \ne \Theta(f(n))$ for some constant $k\geq1$?

I have encountered the following question in my homework assignment in Data Structures course:

"Does a function $ f$ exists such that: $ f(n-k) \ne \Theta(f(n))$ for some constant $ k\geq1$ ?"

I think no such function $ f$ exists, but I do not know how to prove it (or give a counter-example if one exists).

How to check effeciently that some changes preserve the topological ordering?

I have an acyclic directed graph with $ k$ connected components. I also have a topological ordering $ L$ (a sequence of vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering).

So, let’s say for example $ L = i_0,i_1,..,i_n$ .

I have the following operations:

  1. Exchange(i,j): it simply exchange the positions of i and j in the list. Meaning that $ L = ..,i,..,j,..$ becomes $ L’=..,j,..,i..$

  2. Inserting(i,p): it simply remove $ i$ from its position and inserts it in position $ p$ . Meaning that we have $ L=a,b,c,i,d,e,f$ then inserting(i,6) gives $ L”=a,b,c,d,e,i,f$ .

Now how to check that $ L’$ and $ L”$ are also valid topological sorting? Apart from doing a graph traversal of course because I want to exploit the two facts: i) the graph comes in $ k$ connected components and ii) some parts of $ L$ remain unchanged in $ L’$ and $ L”$ so its not useful to check them. Please consider indicating the complexity of your approaches.

Need some advices in beginning in white-hat [closed]

I’ve just started learning white-hat hacking and need some advices. Firstly, where I can get tasks from Linux and bash to practice, because I cannot find them in the Net? Secondly, where I can get tasks from python to practice, because there aren’t a wide range of sites with this topic? Also, if it is possible, can you write some advices to me how to learn and practice in white-hat hacking better, because it’s my dream.

What prevents me from using a some server’s public key and impersonate another server [duplicate]

I read alot regarding RSA encryption/DH key exchange/digital signatures and the whole TLS protocol.

There’s something i am missing regarding the public key signatue validation.

Let say some website has a certificate signed with its private key, as a client I have access to the public key.

But if the server only sends the public key to the client, what is preventing me as an attacker from taking this public key, and returning it to who ever wants to communicate with me.

I mean, where is the private-key authentiction comes to place?

I created this small C# code to demostrate:

private const int _port = 4455; static void Main(string[] args) {     Task.Run(async () =>     {         await TcpServerInit();     });      Task.Run(async () =>     {         await TcpClientInit();     });      Console.ReadLine(); }  private static async Task TcpServerInit() {     var server = new TcpListener(IPAddress.Any, _port);     server.Start();      while (true)     {         TcpClient client = await server.AcceptTcpClientAsync();         using (var netStream = client.GetStream())         {             ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate;             ServicePointManager.Expect100Continue = true;              using (var ssl = new SslStream(netStream, false))             {                 using (var cert = new X509Certificate2(@"MyPublicCert.cer"))                 {                     await ssl.AuthenticateAsServerAsync(cert, false, SslProtocols.Tls12, true);                 }             }         }     } }  private static async Task TcpClientInit() {     using (TcpClient client = new TcpClient("localhost", _port))     {         using (SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateCertificate), null))         {             var servername = "CN=localhost";             await sslStream.AuthenticateAsClientAsync(servername);             byte[] messsage = Encoding.UTF8.GetBytes("Hello");             sslStream.Write(messsage);             sslStream.Flush();          }     } }    private static bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {     //cert validation     return true; } 

site does not respond to some sql injection commands [closed]

I work on a target that I know has SQL injection bug, because in this URL:*+form+aduan.emel 

I get this answer

Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Select * form aduan.emel’ ORDER BY transaksi_aduan.no_pendaftaran asc’ at line 11

But some sql commands, like UNION SELECT @@version-- and Union+select+NUll,null-- don’t work!

When I submit them, the server responds with error 500.

Why does this happen? I think it is the firewall, is there any way to bypass it?

Notice: I have tried all the tamper options in sqlmap, but they didn’t work and the server returned: connection timed out to the target URL or proxy

I also tried –tor but it didn’t work.

Where is the problem?