开发者

How do I represent a GUID in a json object?

开发者 https://www.devze.com 2023-01-25 20:24 出处:网络
For GUID type in JS开发者_开发百科ON, do we need double quote like \"Id\": \"9903ED01-A73C-4874-8ABF-D2678E3AE23D\"

For GUID type in JS开发者_开发百科ON, do we need double quote like

"Id": "9903ED01-A73C-4874-8ABF-D2678E3AE23D" 

or just like

"Id" : 9903ED01-A73C-4874-8ABF-D2678E3AE23D


There is no such thing as a 'GUID Type.'

You need to put it in quotes. A GUID is just a string, and string need quotes.

All of the types are listed here on the JSON website. (Look on the right side)


Guid Should be passed with quotes

"Id" : "9903ED01-A73C-4874-8ABF-D2678E3AE23D"


Simple {"a241306c-235d-4cab-a728-a18236844776"} worked for me.


I was trying to deserialize JSON into a class

public class EraseData
{
    public int Size { get; set; }

    public IEnumerable<Guid> EnterpriseIds { get; set; }
}

and this was valid JSON syntax.

{
  "Size": 10,
  "EnterpriseIds": [
    "a241306c-235d-4cab-a728-a18236844776",
    "977fbb1d-5d3f-47a5-a33d-0762ef5d9ac7"
  ]
}
0

精彩评论

暂无评论...
验证码 换一张
取 消