question

SantLipi-6526 avatar image
0 Votes"
SantLipi-6526 asked ZhiLv-MSFT commented

Convert python object to jObject in C#

Hi ,
Below i am using Jobject trying to convert payton to c#.


Python object which is assigned new value.
Payload["test1"]["test2"] = {"value": "example", "source":15};


In C#

Payload["test1"]["test2"] = JObject.FromObject(new Dictionary<object,object>
{
{
"value","example"
},
{
"source",15
}
});

Is it the right way of assing value to payload in c#


dotnet-csharpdotnet-aspnet-core-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SantLipi-6526,

By using the converted C# code, the result as below, is that what you want?

111751-capture2.png

If the above achieve your requirement, you could also refer the following code, use JObject.Parse method to parse a JSON string, which will get the same result.

         var value = "{ \"value\": \"example\", \"source\":15}";
         var result2 = JObject.Parse(value);

If I misunderstand your question, please let me know freely, and tell me what the Payload["test1"]["test2"] looks that, because I'm not familiar with python.

0 Votes 0 ·
capture2.png (8.5 KiB)

0 Answers