Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6355817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:50:30+00:00 2026-05-24T22:50:30+00:00

I use mongodb with Rest. Every document is composed of a field Id(Guid) and

  • 0

I use mongodb with Rest. Every document is composed of a field Id(Guid) and Name (string)

Here’s what’s displayed when I access the webpage :

"_id" : { "$binary" : "Oq4RFClrRUOtIp89AQTGPw==",
        "$type" : "03"
"name" : "HelloWorld"

In mongodb, my Guid was transformed into a UUID (say my JMongoBrowser) and is displayed as 46eb229f-b493-5630-b0d7-aa00499fafa0.

But when I access my rest webpage, It’s cutted in two parts (a binary, and a type). So how can I cast it into C# object ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:50:32+00:00Added an answer on May 24, 2026 at 10:50 pm

    The string is a base-64 encoded string representing the guid’s byte array, but you need to deal with byte UUD encoding, so you can have it back like this:

    public static Guid ToGuid(string jsonUuid)
    {
        byte[] bytes = Convert.FromBase64String(jsonUuid);
        byte[] rbytes = new byte[16];
        rbytes[0] = bytes[4];
        rbytes[1] = bytes[5];
        rbytes[2] = bytes[6];
        rbytes[3] = bytes[7];
        rbytes[4] = bytes[2];
        rbytes[5] = bytes[3];
        rbytes[6] = bytes[0];
        rbytes[7] = bytes[1];
        rbytes[8] = bytes[15];
        rbytes[9] = bytes[14];
        rbytes[10] = bytes[13];
        rbytes[11] = bytes[12];
        rbytes[12] = bytes[11];
        rbytes[13] = bytes[10];
        rbytes[14] = bytes[9];
        rbytes[15] = bytes[8];
        return new Guid(rbytes);
    }
    

    or like this:

    public static Guid ToGuid(string jsonUuid)
    { 
        return new Guid(Convert.FromBase64String(jsonUuid));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use the standard MongoDB ReST interface ( http://www.mongodb.org/display/DOCS/Http+Interface ) to search
I use mongodb-erlang driver for mongo db access in erlang. Some of my command
I lovely update a document with values(Maps coord) from clienside (under privileges). MongoDB use
I want to try to use MongoDB to access large millions of rows of
I'm trying to use MongoDB to store a series of documents. These document share
Can I use MongoDB and a PostgreSQL in one rails app? Specifically I will
I am starting to use mongodb for data storage. In mysql I save a
i'm trying to use mongodb as a network wide configuration storage. This the same
I have a good reason to use MongoDB for part of my app. But
Is it a good idea to use MongoDB in .NET desktop application?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.