Skip to content

Keep Trailing zeros when Parsing Json using jayway JsonPath #542

@vpadhudev

Description

@vpadhudev

I am using jayway json-path - 2.4.0 to parse Json. When Parsing json, if the json contains any double value, its truncating the trailing zeros. For Example, I have a Json String like below.

{"name" : "Paddy" , "value": 60.10}

And my Code:

package com.test;

import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import java.math.BigDecimal;

public class TestClas {

  public static void main(String[] args) {

    String value = "{\"name\" : \"Paddy\" , \"value\": 60.10}";
    DocumentContext docCtx = JsonPath.parse(value);
    JsonPath jsonPath = JsonPath.compile("$.value");
    Object result = docCtx.read(jsonPath);
    System.out.println(result);
  }
}

And it just prints 60.1, but I need 60.10. How to get the result without truncating trailing zeros.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions