Long int id's and javascript json serialization

Doing preliminary research on using long id’s with a couple tables…

I’ve come across the following SO posts on the topic.

  1. ServiceStack serialization of long int value
  2. ServiceStack : Serialize long number to string

It would seem the issue would be JavaScript interpreting long ints past a certain value. Is the following still the best way and the recommended way to handle it to work on the JavaScript client?

// https://stackoverflow.com/questions/32695359/servicestack-serialize-long-number-to-string
JsConfig<long>.RawSerializeFn = (long num) =>
            {
                if (num > 9007199254740991L || num < -9007199254740991L)
                    return string.Format("\"{0}\"", num);
                return num.ToString();
            };

Maybe in the case of id’s it should always be a string. No math will be used on the ids.

JsConfig<long>.RawSerializeFn = (long num) =>
            {
                // changed to single quotes instead of double quotes
                return string.Format("'{0}'", num);
            };

Or would it be better to create each DTO with a long int id as string and leave the data model as long and do the parsing between the DTO and the data model? I think this would probably be the better option, unless there is something missing.

public class HelloService : Service
    {
        public object Post(Hello request)
        {
            if (!request.Name.IsNullOrEmpty())
            {
                Db.Insert(new HelloModel
                {
                    Id = request.Id.ToInt64(),
                    Name = request.Name
                });
            }
            return new HelloResponse { Result = $ "Hello, {request.Name}!" };
        }

        [Route("/hello")]
        [Route("/hello/{Name}")]
        public class Hello : IReturn<HelloResponse>
        {
            public string Id { get; set; }
            public string Name { get; set; }
        }

        public class HelloResponse
        {
            public string Result { get; set; }
        }
    }

// Data Model

    [Alias("hello")]
    public class HelloModel
    {
        [AutoIncrement]
        [PrimaryKey]
        [ReturnOnInsert]
        [Alias("hello_id")]
        public long Id { get; set; }
        public string Name { get; set; }
    }

Note: The space after the “$” (string interpolation) is needed for the SS forum as it seems the markdown converts it to a guid without hyphens when it is next to a double quote in a code section.

Rather than trying to override serialization of longs I would just have the property a string if you need it, but do you have an example showing the problem?