* backport of commit d91c194e72
* backport of commit d05df36d77
* backport of commit 2531018f36
* backport of commit 1768215b6b
* backport of commit 47cd24fb3d
---------
Co-authored-by: Xinyi Wang <xinyi.wang@hashicorp.com>
We serially attempt to decode resources in the consul resource apply command
using HCL and then falling back on JSON. This causes the HCL errors to be
dropped completely in the case where the HCL decode failed due to a typo
instead of it actually being JSON instead.
This PR proposes sniffing to see if the first non-whitespace character in the
input is { and if so treat it as JSON, otherwise as HCL and not
double-decode on error.
* add cli support for json format
* add tests for json parsing
* make owner and id pointers.
* add copyright header
* remove print
---------
Co-authored-by: Poonam Jadhav <poonam.jadhav@hashicorp.com>