简体   繁体   English

我如何将 json 转换为 c# 中的字节数组

[英]How do i convert a json to a byte array in c#

i have pretty much zero experience with this and have tried for a lot longer than id like to admit to make this work but i am at a roadblock and cant make this thing that should be simple work.我对此的经验几乎为零,并且尝试的时间比我承认的要完成这项工作的时间要长得多,但是我遇到了障碍,无法使这件事变得简单。 i am new and know basically nothing about it and i cannot understand the documentation and google searches lead to nothing.我是新手,基本上对此一无所知,我无法理解文档,谷歌搜索一无所获。 it currently being 1 am surely doesnt help either.目前是凌晨 1 点肯定也无济于事。 my current try is this:我目前的尝试是这样的:

byte[] jsonData = new byte[]{JsonSerializer.SerializeToUtf8Bytes({ v: 1,client_id: 332269999912132097})};

could you try this你能试试这个吗

byte[] obj = yourobj.Tostring().getBytes("UTF-8");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM