Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
JSON Property names with dots in Javascript using Jackson-like library

I need to create a Json with field names with dots '.' in javascript application (typescript)

Json expected output:

{
    "tasks.max": "1",
    "key.converter": "io.confluent.connect.avro.AvroConverter",
    "topics": "eraseme_topic_schema_test_v05"
 }

I have tried ts-jackson and jackson-js, Code example using ts-jackson

MyDomain.ts

@Serializable()
import { JsonProperty,Serializable } from 'ts-jackson';
export class MyDomain{
        @JsonProperty({path: 'tasks.max', elementType: String})
        tasks_max: string;
        @JsonProperty({path: 'key.converter'})
        key_converter: string;
        @JsonProperty({path: 'topics'})
        topics: string;
}

But the properties with dots are created as subclasses in Json output instead a property field with dot.

{
  tasks: { max: '1' },
  key: { converter: { schema: [Object] } },
  topics: 'eraseme_topic_schema_test_v05'
}

How can I set dots in Json fields name in Javascript using a Jackson-like library?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This comment by joniba on the lodash github repo shows how to access properties containing dots using lodash:

// lodash set
const o = {}
_.set(o, 'a["b.c"]', 1)
// returns { a: { 'b.c': 1 } }

This works with lodash get:

// lodash get
const obj = {'a.b': 'value'};
_.get(obj, '["a.b"]'); // 'value'

So it should be possible to write the ts-jackson path properties like this:

export class MyDomain{
    @JsonProperty({path: '["tasks.max"]', elementType: String})
    tasks_max: string;
    @JsonProperty({path: '["key.converter"]'})
    key_converter: string;
    @JsonProperty({path: 'topics'})
    topics: string;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!