2016-04-18 00:36:00 +03:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=9" / >
2016-09-12 00:34:59 +03:00
< meta name = "generator" content = "Doxygen 1.8.12" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
2016-04-18 00:36:00 +03:00
< title > JSON for Modern C++: nlohmann::basic_json::json_pointer::json_pointer< / title >
< link href = "tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "jquery.js" > < / script >
< script type = "text/javascript" src = "dynsections.js" > < / script >
< link href = "search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "search/searchdata.js" > < / script >
< script type = "text/javascript" src = "search/search.js" > < / script >
< link href = "doxygen.css" rel = "stylesheet" type = "text/css" / >
< link href = "mylayout.css" rel = "stylesheet" type = "text/css" / >
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
< tr style = "height: 56px;" >
< td id = "projectalign" style = "padding-left: 0.5em;" >
< div id = "projectname" > JSON for Modern C++
2017-01-02 18:32:45 +03:00
  < span id = "projectnumber" > 2.0.10< / span >
2016-04-18 00:36:00 +03:00
< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2016-09-12 00:34:59 +03:00
<!-- Generated by Doxygen 1.8.12 -->
2016-04-18 00:36:00 +03:00
< script type = "text/javascript" >
var searchBox = new SearchBox("searchBox", "search",false,'Search');
< / script >
2016-09-12 00:34:59 +03:00
< script type = "text/javascript" src = "menudata.js" > < / script >
< script type = "text/javascript" src = "menu.js" > < / script >
< script type = "text/javascript" >
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
< / script >
< div id = "main-nav" > < / div >
2016-04-18 00:36:00 +03:00
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< iframe src = "javascript:void(0)" frameborder = "0"
name="MSearchResults" id="MSearchResults">
< / iframe >
< / div >
< div id = "nav-path" class = "navpath" >
< ul >
< li class = "navelem" > < a class = "el" href = "namespacenlohmann.html" > nlohmann< / a > < / li > < li class = "navelem" > < a class = "el" href = "classnlohmann_1_1basic__json.html" > basic_json< / a > < / li > < li class = "navelem" > < a class = "el" href = "classnlohmann_1_1basic__json_1_1json__pointer.html" > json_pointer< / a > < / li > < / ul >
< / div >
< / div > <!-- top -->
< div class = "contents" >
< table cellspacing = "0" cellpadding = "0" border = "0" >
< tr >
< td valign = "top" >
< div class = "navtab" >
< table >
< tr > < td class = "navtab" > < a class = "qindex" href = "classnlohmann_1_1basic__json_1_1json__pointer_ada3100cdb8700566051828f1355fa745.html#ada3100cdb8700566051828f1355fa745" > basic_json< / a > < / td > < / tr >
< tr > < td class = "navtab" > < a class = "qindexHL" href = "classnlohmann_1_1basic__json_1_1json__pointer_ae12db117a2742d826465080979d7c835.html#ae12db117a2742d826465080979d7c835" > json_pointer< / a > < / td > < / tr >
2016-09-12 00:34:59 +03:00
< tr > < td class = "navtab" > < a class = "qindex" href = "classnlohmann_1_1basic__json_1_1json__pointer_a319e945a9349ed49fe3a62bc023c8d23.html#a319e945a9349ed49fe3a62bc023c8d23" > operator std::string< / a > < / td > < / tr >
< tr > < td class = "navtab" > < a class = "qindex" href = "classnlohmann_1_1basic__json_1_1json__pointer_a5670f575e57c3b1feb3e934a345d1aaa.html#a5670f575e57c3b1feb3e934a345d1aaa" > to_string< / a > < / td > < / tr >
2016-04-18 00:36:00 +03:00
< / table >
< / div >
< / td >
< td valign = "top" class = "mempage" >
2016-09-12 00:34:59 +03:00
< a id = "ae12db117a2742d826465080979d7c835" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ae12db117a2742d826465080979d7c835" > § < / a > < / span > json_pointer()< / h2 >
2016-04-18 00:36:00 +03:00
< div class = "memitem" >
< div class = "memproto" >
< div class = "memtemplate" >
2016-09-12 00:34:59 +03:00
template< template< typename U, typename V, typename... Args > class ObjectType = std::map, template< typename U, typename... Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = std::int64_t, class NumberUnsignedType = std::uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator> < / div >
2016-04-18 00:36:00 +03:00
< table class = "mlabels" >
< tr >
< td class = "mlabels-left" >
< table class = "memname" >
< tr >
< td class = "memname" > < a class = "el" href = "classnlohmann_1_1basic__json.html" > nlohmann::basic_json< / a > ::json_pointer::json_pointer < / td >
< td > (< / td >
< td class = "paramtype" > const std::string &   < / td >
< td class = "paramname" > < em > s< / em > = < code > " " < / code > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / td >
< td class = "mlabels-right" >
< span class = "mlabels" > < span class = "mlabel" > inline< / span > < span class = "mlabel" > explicit< / span > < / span > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Create a JSON pointer according to the syntax described in < a href = "https://tools.ietf.org/html/rfc6901#section-3" > Section 3 of RFC6901< / a > .< / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > s< / td > < td > string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value< / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "exception" > < dt > Exceptions< / dt > < dd >
< table class = "exception" >
< tr > < td class = "paramname" > std::domain_error< / td > < td > if reference token is nonempty and does not begin with a slash (< code > /< / code > ); example: < code > "JSON pointer must be empty or
begin with /"< / code > < / td > < / tr >
< tr > < td class = "paramname" > std::domain_error< / td > < td > if a tilde (< code > ~< / code > ) is not followed by < code > 0< / code > (representing < code > ~< / code > ) or < code > 1< / code > (representing < code > /< / code > ); example: < code > "escape error:
~ must be followed with 0 or 1"< / code > < / td > < / tr >
< / table >
< / dd >
< / dl >
2017-01-04 20:11:15 +03:00
< dl class = "section user" > < dt > Example< / dt > < dd > The example shows the construction several valid JSON pointers as well as the exceptional behavior. < div class = "fragment" > < div class = "line" > < a name = "l00001" > < / a > < span class = "lineno" > 1< / span >   < span class = "preprocessor" > #include < json.hpp> < / span > < / div > < div class = "line" > < a name = "l00002" > < / a > < span class = "lineno" > 2< / span >   < / div > < div class = "line" > < a name = "l00003" > < / a > < span class = "lineno" > 3< / span >   < span class = "keyword" > using< / span > < a class = "code" href = "namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html#a2bfd99e845a2e5cd90aeaf1b1431f474" > json< / a > = < a class = "code" href = "namespacenlohmann_a2bfd99e845a2e5cd90aeaf1b1431f474.html#a2bfd99e845a2e5cd90aeaf1b1431f474" > nlohmann::json< / a > ;< / div > < div class = "line" > < a name = "l00004" > < / a > < span class = "lineno" > 4< / span >   < / div > < div class = "line" > < a name = "l00005" > < / a > < span class = "lineno" > 5< / span >   < span class = "keywordtype" > int< / span > main()< / div > < div class = "line" > < a name = "l00006" > < / a > < span class = "lineno" > 6< / span >   {< / div > < div class = "line" > < a name = "l00007" > < / a > < span class = "lineno" > 7< / span >   < span class = "comment" > // correct JSON pointers< / span > < / div > < div class = "line" > < a name = "l00008" > < / a > < span class = "lineno" > 8< / span >   json::json_pointer p1;< / div > < div class = "line" > < a name = "l00009" > < / a > < span class = "lineno" > 9< / span >   json::json_pointer p2(< span class = "stringliteral" > " " < / span > );< / div > < div class = "line" > < a name = "l00010" > < / a > < span class = "lineno" > 10< / span >   json::json_pointer p3(< span class = "stringliteral" > " /" < / span > );< / div > < div class = "line" > < a name = "l00011" > < / a > < span class = "lineno" > 11< / span >   json::json_pointer p4(< span class = "stringliteral" > " //" < / span > );< / div > < div class = "line" > < a name = "l00012" > < / a > < span class = "lineno" > 12< / span >   json::json_pointer p5(< span class = "stringliteral" > " /foo/bar" < / span > );< / div > < div class = "line" > < a name = "l00013" > < / a > < span class = "lineno" > 13< / span >   json::json_pointer p6(< span class = "stringliteral" > " /foo/bar/-" < / span > );< / div > < div class = "line" > < a name = "l00014" > < / a > < span class = "lineno" > 14< / span >   json::json_pointer p7(< span class = "stringliteral" > " /foo/~0" < / span > );< / div > < div class = "line" > < a name = "l00015" > < / a > < span class = "lineno" > 15< / span >   json::json_pointer p8(< span class = "stringliteral" > " /foo/~1" < / span > );< / div > < div class = "line" > < a name = "l00016" > < / a > < span class = "lineno" > 16< / span >   < / div > < div class = "line" > < a name = "l00017" > < / a > < span class = "lineno" > 17< / span >   < span class = "comment" > // error: JSON pointer does not begin with a slash< / span > < / div > < div class = "line" > < a name = "l00018" > < / a > < span class = "lineno" > 18< / span >   < span class = "keywordflow" > try< / span > < / div > < div class = "line" > < a name = "l00019" > < / a > < span class = "lineno" > 19< / span >   {< / div > < div class = "line" > < a name = "l00020" > < / a > < span class = "lineno" > 20< / span >   json::json_pointer p9(< span class = "stringliteral" > " foo" < / span > );< / div > < div class = "line" > < a name = "l00021" > < / a > < span class = "lineno" > 21< / span >   }< / div > < div class = "line" > < a name = "l00022" > < / a > < span class = "lineno" > 22< / span >   < span class = "keywordflow" > catch< / span > (std::domain_error& e)< / div > < div class = "line" > < a name = "l00023" > < / a > < span class = "lineno" > 23< / span >   {< / div > < div class = "line" > < a name = "l00024" > < / a > < span class = "lineno" > 24< / span >   std::cout < < < span class = "stringliteral" > " domain_error: " < / span > < < e.what() < < < span class = "charliteral" > ' \n' < / span > ;< / div > < div class = "line" > < a name = "l00025" > < / a > < span class = "lineno" > 25< / span >   }< / div > < div class = "line" > < a name = "l00026" > < / a > < span class = "lineno" > 26< / span >   < / div > < div class = "line" > < a name = "l00027" > < / a > < span class = "lineno" > 27< / span >   < span class = "comment" > // error: JSON pointer uses escape symbol ~ not followed by 0 or 1< / span > < / div > < div class = "line" > < a name = "l00028" > < / a > < span class = "lineno" > 28<
2016-05-12 08:38:02 +03:00
< / div > <!-- fragment --> Output (play with this example < a target = "_blank" href = "http://melpon.org/wandbox/permlink/WM2WWKnXdmdw17Wu" > < b > online< / b > < / a > ): < pre class = "fragment" > domain_error: JSON pointer must be empty or begin with '/'
2016-04-18 00:36:00 +03:00
domain_error: escape error: '~' must be followed with '0' or '1'
domain_error: escape error: '~' must be followed with '0' or '1'
< / pre > The example code above can be translated with< pre class = "fragment" > g++ -std=c++11 -Isrc doc/examples/json_pointer.cpp -o json_pointer < / pre > < / dd > < / dl >
< dl class = "section since" > < dt > Since< / dt > < dd > version 2.0.0 < / dd > < / dl >
2017-01-04 20:11:15 +03:00
< p > Definition at line < a class = "el" href = "json_8hpp_source.html#l10920" > 10920< / a > of file < a class = "el" href = "json_8hpp_source.html" > json.hpp< / a > .< / p >
2016-04-18 00:36:00 +03:00
< / div >
< / div >
< / td >
< / tr >
< / table >
< / div > <!-- contents -->
<!-- start footer part -->
< hr class = "footer" / > < address class = "footer" > < small >
2017-01-04 20:11:15 +03:00
Generated on Wed Jan 4 2017 18:08:40 for JSON for Modern C++ by   < a href = "http://www.doxygen.org/index.html" >
2016-04-18 00:36:00 +03:00
< img class = "footer" src = "doxygen.png" alt = "doxygen" / >
2016-09-12 00:34:59 +03:00
< / a > 1.8.12
2016-04-18 00:36:00 +03:00
< / small > < / address >
< / body >
< / html >